has2k1 / plotnine

A Grammar of Graphics for Python
https://plotnine.org
MIT License
4k stars 213 forks source link

Legend now always in 2 rows (text is below and not right to symbol) when using theme(legend_position='bottom') #761

Closed TerryGamon closed 6 months ago

TerryGamon commented 6 months ago

The Legend is now in 2 Rows (text is below and not right to symbol) when using plotnine.theme(legend_position='bottom') even whentrying to change number of rows to one.

Is this intended? Couldn't find anything regarding this in changelog.

import pandas as pd
import numpy as np
import plotnine
np.random.seed(42)
data = {
    'Alphanumeric': ['A1', 'B2', 'C3', 'D4', 'E5'],
    'RandomInt1': np.random.randint(0, 100, size=5),
    'RandomInt2': np.random.randint(0, 100, size=5)
}
df = pd.DataFrame(data)

(plotnine.ggplot(df)
 +plotnine.geom_point(plotnine.aes(x='RandomInt1',y='RandomInt2', color='Alphanumeric'))
 +plotnine.theme(legend_position='bottom')
 +plotnine.guides(color=plotnine.guide_legend(nrow=1))
 )

image