axis-labels

Rotate Label Axis X in a specific subplot using sns.boxplot (seaborn)

Rotate xtick labels of a specific subplot Question: How to rotate in 90° the labels of X axis of subplot 222 (chart 2) and keep using sns.boxplot? fig = plt.figure(figsize=(12, 8)) # CHART 1 fig.add_subplot(221) #sns.countplot(df_train[‘MSZoning’]) sns.boxplot(x=’MSZoning’, y=’SalePrice’, data=df_train) # CHART 2 fig.add_subplot(222) #sns.boxplot(x=’MSZoning’, y=’SalePrice’, data=df_train) sns.boxplot(x=’Neighborhood’, y=’SalePrice’, data=df_train) # CHART 3 fig.add_subplot(223) #sns.boxplot(x=’Neighborhood’, y=’SalePrice’, …

Total answers: 1

How to set order of x-axis on sns histplot?

How to set order of x-axis on sns histplot? Question: The ‘floorType’ was originally character variable that I changed into integer (1,2,3,4,5) through Excel. But when I loaded that cvs. file into Jupyter and draw sns histogram of this variable, the order of axis is shown as (4 -> 5 -> 3 -> 2 -> …

Total answers: 1

Remove zero from ternary plot

Remove zero from ternary plot Question: I have the following plot and I want to remove the 0 in the origins. import plotly.graph_objects as go import plotly.express as px fig = go.Figure(go.Scatterternary({ ‘mode’: ‘markers’, ‘a’: [0.3],’b’: [0.5], ‘c’: [0.6], ‘marker’: {‘color’: ‘AliceBlue’,’size’: 14,’line’: {‘width’: 2} }, })) fig.update_layout({ ‘ternary’: { ‘sum’: 100, ‘aaxis’: {‘nticks’:1, ‘ticks’:""}, …

Total answers: 1

Repeated Categorical X-Axis Labels in Matplotlib

Repeated Categorical X-Axis Labels in Matplotlib Question: I have a simple question: why are my x-axis labels repeated? Here’s an MWE: X-Axis Labels MWE a = { # DATA — ‘CATEGORY’: (VALUE, ERROR) ‘Cats’: (1, 0.105), ‘Dogs’: (2, 0.023), ‘Pigs’: (2.6, 0.134) } compositions = list(a.keys()) # MAKE INTO LIST a_vals = [i[0] for i …

Total answers: 1

How to center x/y labels on the visible axes spine, not the plot area

How to center x/y labels on the visible axes spine, not the plot area Question: My plot has ylim(0,0.08), but I am only displaying up to 0.06. The problem is, my ylabel is centered on a spine that is 0.08, instead of 0.06. Is there a way to have the label centered only on the …

Total answers: 2

Aligning rotated xticklabels and ylabels with their respective xticks and yticks

Aligning rotated xticklabels and ylabels with their respective xticks and yticks Question: Here is the output of the code : array = [[64,7,5], [9,195,1], [6,17,2]] df_cm = pd.DataFrame(array, range(3), range(3)) sn.set(font_scale=1.4) # for l)abel size sn.heatmap(df_cm, annot=True, annot_kws={"size": 16}, cmap=’Blues’, fmt=’g’) # font size class_names = [‘dog’,’cat’,’bear’] plt.gca().xaxis.tick_top() plt.gca().xaxis.set_label_position(‘top’) tick_marks = np.arange(len(class_names)) plt.xticks(tick_marks, class_names, rotation=45, …

Total answers: 1

How do we label a matrix plot with a predefined list of labels (e.g. a list of prime numbers)?

How do we label a matrix plot with a predefined list of labels (e.g. a list of prime numbers)? Question: I have a CSV File with elliptic curve related data which looks as follows (excerpt): 3,19,[(1,4,1),(4,7,44)] 3,13,[(4,1,10)] 5,11,[(4,39,14)] 3,7,[(1,2,1),(1,3622,111),(4,17,10)] 3,5,[(4,1,2),(4,959,124)] 3,23,[(3,5,2)] 5,13,[(2,7,2),(2,8,1),(2,47,70),…] 7,11,[(1,2,1),(1,13,2),(1,53,4),…] 3,29,[(4,13,4)] 5,17,[(2,2,3),(4,6881,498)] 5,19,[(4,71,18)] 3,37,[(4,25,14)] 7,17,[(4,19,30)] 7,19,[(3,66,5)] The first and second number in …

Total answers: 1

matplotlib modify outer x label and keep inner x label

matplotlib modify outer x label and keep inner x label Question: I have a plot with 2 x_labels for two subplots. The inner x label is "Bronx, Brooklyn, Manhanttan, Queens, Staten Island"(or is it call x tick?), the outer x label is "borough": I want to find two different solutions to handle the "borough" labels. …

Total answers: 1

Rotate axis labels

Rotate axis labels Question: I have a plot that looks like this (this is the famous Wine dataset): As you can see, the x-axis labels overlap and thus I need to be rotated. NB! I am not interested in rotating the x-ticks (as explained here), but the label text, i.e. alcohol, malic_acid, etc. The logic …

Total answers: 2

Placement of Y labels plotly python horizontal barchart

Placement of Y labels plotly python horizontal barchart Question: I’m looking for a way to get the y labels of a plotly horizontal barchart above the grouped bars. What i’m looking for is: import pandas as pd import plotly.graph_objects as go test_df = pd.DataFrame({‘component’:[‘BAR 1′,’BAR 2′,’BAR 3′],’mean’:[7.4,7.8,6.5],’mean_proj’:[6.8,7.9,8.4]}) def barchart2(df,x1,x2,y): fig = go.Figure() fig.add_trace(go.Bar(name=x1,x=df[x1],y=df[y],orientation=’h’,hoverinfo=None,marker_color=’#221435′)), fig.add_trace(go.Bar(name=x2,x=df[x2],y=df[y],orientation=’h’,hoverinfo=None,marker_color=’rgb(55,177,140)’)), fig.update_xaxes(showgrid=False, …

Total answers: 2