This question already has an answer here:
Adjust y-axis in Seaborn multiplot
(1 answer)
Closed 2 years ago.
Hello I'm learning seaborn, pandas and matplotlib and trying to visualize some data.
Im trying to move the 0 value in 0 axis to x axis. This is how it looks currently and I want to move it down.
You can use:
sns.regplot(x,y)
plt.ylim(0)
Related
This question already has answers here:
How to plot percentage with seaborn distplot / histplot / displot
(3 answers)
Plot a horizontal line on a given plot
(7 answers)
Box around text in matplotlib
(3 answers)
Closed 3 months ago.
I'm tring to create a Clustering Situation, with KMeans.
This is how my datasets looks like:
With these dataset, I apply FacetGrid this way:
for c in data:
grid= sns.FacetGrid(data, col='Clusters')
grid.map(plt.hist,c)
grid.set_xticklabels(rotation=90)
Output:
For all features.
This is working ok, but the FacetGrid only show Feature Value X Count for each clusters...
This information is not too relevant too me, since all clusters have different 'len'.
E.g Customer Age for Cluster 1 plot is very higher than Customer Age for Cluster 0, since Cluster 1 has more elements.
What I need:
I need a way to compare each column of the plot relative to its total.
E.g
I'd like to see:
For each cluster and each feature.
Is it possible?
Thank you.
This question already has answers here:
How to adjust padding with cutoff or overlapping labels
(8 answers)
matplotlib savefig - text chopped off
(3 answers)
Closed 4 months ago.
I have the following code to create a heatmap with seaborn! unfourtunately my y-ticklabels are long names, and are cut off from the figure as shown in the attached image!
seasons = ['yearly','djf','mam','jja','son']
for season_index,season in enumerate(['yearly','djf','mam','jja','son']):
im = sns.heatmap(bias[:,season_index,:],linewidth = 0.5,cmap='coolwarm', annot=True,annot_kws={'fontsize':7, 'fontweight':'bold'})
im.set_xticklabels(['1','2','3','4','5','6','7','8','9'])
im.set_yticklabels(model_list)
plt.savefig(f"figures/bias/yearly_bias_{seasons[season_index]}.png")
plt.close()
I tried changing the figure size with matplotlib, but everytime i did that, the tick labels would rotate 90° and overlap, and in my code it didn't work to reset it with the rotation keyword in the set_yticklabels function.
i also tried this but that had the same result in turning the labels.
Thank you!
plt.tight_layout()
this worked, thank you ver ymuch to Nikita Shabankin!
This question already has answers here:
Using pandas value_counts and matplotlib
(1 answer)
how to sort the result by pandas.value_counts
(1 answer)
Unnormalized histogram plots in Seaborn are not centered on X-axis
(1 answer)
Differences between seaborn histogram, countplot and distplot
(1 answer)
Closed 8 months ago.
I have a binary column in pandas dataframe. I want to visualize it, just to see how much there is 0 or 1. I used displot:
Plot = sns.displot(data = data, x = 'stroke', color = 'm')
Plot.fig.suptitle('Stroke numbers in data', size=15, y=1.12);
This did the job but it's very ugly, how do I make it only with 0 and 1 ?:
I think this is a good solution:
data["stroke"].value_counts(sort=False).plot.bar(rot=0)
This question already has answers here:
Matplotlib y axis values are not ordered [duplicate]
(1 answer)
Difference in plotting with different matplotlib versions
(1 answer)
Closed 10 months ago.
The values on the y axis of this plot are too clustered, as seen where I labelled 1 in the picture.
The only was to make the numbers slightly visible is the reduce the value of labelsize= in the tick_params() method but that mades the values so small they are unreadable.
Do I have to plot all the points in the range of my list rainfall in line 16 or can I specifiy which labels I would like to place?
This question already has answers here:
matplotlib create broken axis in subplot
(1 answer)
remove part of a plot in matplotlib
(1 answer)
Closed 5 years ago.
I want to define range of x values appeared in plot in python. For example, here is my code:
import matplotlib.pyplot as plt
plt.figure(13)
ax1=plt.subplot(111)
x=[i for i in range(100)]
y=[i**2 for i in x]
ax1.plot(x,y)
However, I want to see in the graph x ranges from 0 to 60 and 80 to 100. How, I can do it in matplot. Actual, problem is more complicated, just removing data doesn't appear to be good solution. I want to change plot.
I tried ax1.set_xlim([0,60]) but want to see from 80 to 100 also.