how to change the order of factor plot in seaborn
By : user2055256
Date : March 29 2020, 07:55 AM
this will help Your update to the post shows the correct way to do it, i.e. you should pass a list of x values to order in the order you want them plotted. The default for numeric data is to plot in sorted order, so if you have numeric values it's best to keep them as integers or floats instead of strings, so they will be in "natural" order.

How to change order barplot seaborn
By : Keerthi Suria Kumar
Date : March 29 2020, 07:55 AM
Hope that helps I have data as bellow , Reverse both lists inplace before plotting them: code :
df["Shkala"].reverse()
df["Ves"].reverse()
order = list(reversed(df["Shkala"]))

Ascending order of bars in seaborn barplot
By : Mohan
Date : March 29 2020, 07:55 AM
will help you The seaborn hue parameter adds another dimension to the plot. The hue_order determines in which order this dimension is handled. However you cannot split that order. This means you may well change the order such that Age == 2 is in the third place in the plot. But you cannot change it partially, such that in some part it is in the first and in some other it'll be in the third place. In order to achieve what is desired here, namely to use different orders of the auxilary dimensions within the same axes, you need to handle this manually. code :
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
df = pd.DataFrame({"Class" : [2004]*6+[2005]*7,
"Age" : [3,2,4,6,5,1,2,3,6,4,5,1,9],
"Percentage" : [50,40,30,20,10,30,20,35,40,50,45,30,15]})
def sortedgroupedbar(ax, x,y, groupby, data=None, width=0.8, **kwargs):
order = np.zeros(len(data))
df = data.copy()
for xi in np.unique(df[x].values):
group = data[df[x] == xi]
a = group[y].values
b = sorted(np.arange(len(a)),key=lambda x:a[x],reverse=True)
c = sorted(np.arange(len(a)),key=lambda x:b[x])
order[data[x] == xi] = c
df["order"] = order
u, df["ind"] = np.unique(df[x].values, return_inverse=True)
step = width/len(np.unique(df[groupby].values))
for xi,grp in df.groupby(groupby):
ax.bar(grp["ind"]width/2.+grp["order"]*step+step/2.,
grp[y],width=step, label=xi, **kwargs)
ax.legend(title=groupby)
ax.set_xticks(np.arange(len(u)))
ax.set_xticklabels(u)
ax.set_xlabel(x)
ax.set_ylabel(y)
fig, ax = plt.subplots()
sortedgroupedbar(ax, x="Class",y="Percentage", groupby="Age", data=df)
plt.show()

Conversion from string “” to type Long is not valid...If order number is wrong and i tried only numbers not character
By : user1560954
Date : March 29 2020, 07:55 AM
I wish this help you The string "" can not be converted to Long because it is not a number. You can use TryParse to convert the string to Long. If it can not be parsed then 0 is returned into the variable in the second argument (orderQty): code :
Dim orderQty As Long
Long.TryParse(txtOrderQty.Text, orderQty)
lblToBeScanned1.Text = (orderQty  lngUPC1).ToString()

How to control the order of bars in a seaborn barplot
By : user2542634
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I have a dataframe with 4000+ observations and two columns of interest: Revenues and cluster_. , Outdated: code :
sns.barplot(x='cluster_', y='Revenue', data=data7.sort_index())
sorted_keys = ['C', 'B+', 'A+', 'B', 'A'] # for example
sns.barplot(x='cluster_', y='Revenue', data=data7.reindex(sorted_keys))
sns.barplot(x='cluster_', y='Revenue', data=data7, order=['A', 'A+', 'B', 'B+', 'C'])

