I currently have a table as seen below, however I am trying to plot a min and max interval with plotnine, for which I am trying to plot in a more sorted order as it is a mess. Currently I am sorting by the "true"column of my data but this does not seem to have any effect.
DataFrame
CODE
import pandas.api.types as pdtypes
# Convert to tidy data format, making sure to keep the index
sorted_data_long = normalized_sorted_table.melt(value_vars=['min', 'true', 'max'], ignore_index=False).reset_index()
# Make variable a categorical, with categories ordered so as to make sense in the legend
sorted_data_long['variable'] = sorted_data_long['variable'].astype(pdtypes.CategoricalDtype(['min', 'true', 'max']))
# Plot
p9.options.set_option("figure_size", (16, 8))
(p9.ggplot(sorted_data_long, p9.aes('index', y='value', color='variable'))
+ p9.geom_line()
+ p9.labels.ggtitle("PLS: Intervals")
+ p9.theme_bw()
+ p9.theme(text=p9.element_text(size=22)))
Current Output:
Desired Output:
USING:
normalized_sorted_table = normalized_sorted_table.sort_values('true', ignore_index=True)