This question already has answers here:
Rotate label text in seaborn factorplot
(10 answers)
Closed 6 years ago.
I would like to fix label problems in a seaborn graph, I have more than 30 items in the x axis. How to reduce the label dimension or may be rotate the graph?
import seaborn as sns
g = sns.factorplot(x="target", data=df3, kind="count",
palette="BuPu", size=6, aspect=1.5)
This will work if executed in a single cell in Jupyter:
g = sns.factorplot(x="target", data=df3, kind="count",
palette="BuPu", size=6, aspect=1.5)
g.set(xticks=np.arange(0, 40, 3)) # or however many you have
plt.xticks(rotation=90);
It will also work if executed as one block in Spyder.
Related
This question already has answers here:
Setting flier (outlier) style in Seaborn boxplot is ignored
(2 answers)
How to change the figure size of a seaborn axes or figure level plot
(13 answers)
Closed 2 months ago.
Using seaborn I want to change the color of the outlier markers to red. I also want to reduce the width of the figure to get rid of the whitespcace.
This is my current code and the graph it produces:
import seaborn as sns
import matplotlib.pyplot as plt
rbp_box = sns.boxplot(data=df_raw, y="Resting blood pressure", color="red", flierprops={"marker": "x"}, width=0.2)
rbp_box.set(xlabel='', ylabel='mm Hg', title='Resting blood pressure box plot')
box plot
This question already has answers here:
Python Seaborn Facetgrid change xlabels
(2 answers)
Common xlabel/ylabel for matplotlib subplots
(8 answers)
How to add a shared x-label and y-label to a plot created with pandas plot
(4 answers)
One shared x-axis label for Seaborn FacetGrid subplots (layouts/spacing?)
(1 answer)
How to set common axes labels for subplots
(9 answers)
Closed last year.
What I need should be straighforward but I couldn't find a solution. Say we draw the following seaborn.lmplot:
import seaborn as sns; sns.set_theme(color_codes=True)
tips = sns.load_dataset("tips")
g = sns.lmplot(x="total_bill", y="tip", col="day", hue="day",
data=tips, col_wrap=2, height=3)
I simply want to have a single label for the x-axis and a single label for the y-axis instead of two as currently.
In other words, that the word 'tip' be printed only one time on the centre left of the graph, and that the word 'total_bill' be printed only one time on the bottom centre of the graph.
How do we do this?
EDIT: there is a similar question here One shared x-axis label for Seaborn FacetGrid subplots (layouts/spacing?) yet it is not elaborated and does not solve my issue.
This question already has answers here:
How to plot non-square Seaborn jointplot or JointGrid
(3 answers)
Closed 3 years ago.
I am using Jupyter Notebook and want a full width jointplot figure.
I cant seem to get it working though.
g = sns.jointplot(x="pos", y="diff", data=plot_data)
plt.figure(figsize=(16, 6))
doesn't change the size at all.
fig, ax = plt.subplots(figsize=(16, 6))
g = sns.jointplot(ax=ax, x="pos", y="diff", data=plot_data)
Throws an error.
Use the height parameter in the jointplot function to set the size of the figure(it will be square). Refer to official docs: seaborn.pydata.org/generated/seaborn.jointplot.html
This question already has answers here:
matplotlib colorbar in each subplot
(5 answers)
Closed 3 years ago.
I am creating a (10,7) subplot of multiple different gridded fields. The following code is what is being currently used:
fig, axes = plt.subplots(nrows=10, ncols=7, figsize=(18, 16), dpi= 100,
facecolor='w', edgecolor='k')
titles = ['Z1','Z2','Z3','ZDR1','ZDR2','ZDR3','Dist']
for i in range(0,10):
z = 1*10+i
for j in range(0,7):
aa = axes[i,j].matshow(alldata_sim[z,:,:,j], cmap='jet')
fig.colorbar(aa)
axes[0,j].set_title(titles[j])
axes[i,j].get_xaxis().set_visible(False)
axes[i,j].get_yaxis().set_ticks([])
axes[i,0].set_ylabel(allgauge_sim[z])
Which produces the following figure:
Figure1
The question is: how do I get the colorbars to be on the right-hand side of each respective individual subplot?
maybe try changing
fig.colorbar(aa)
to
fig.colorbar(aa,ax=axes[i,j])
Hope it helps!
This question already has answers here:
No outlines on bins of Matplotlib histograms or Seaborn distplots
(3 answers)
Closed 5 years ago.
I wonder why the bins are not showing a boundary between each other. It's confusing to look at it. I attached an example below:
for key,value in dict.items():
plt.figure()
plt.hist( value, bins='auto')
plt.title("Histogram for THR")
plt.show()
That's the new default style for matplotlib 2.0 (for example, see the plots from the documentation for plt.hist in v2.0).
To force the edges of the bins to be displayed you can pass the edgecolor= (or ec=) argument to plt.hist, e.g. plt.hist(values, bins='auto', ec='k') for black bin edges.