mwaskom / seaborn

Statistical data visualization in Python
https://seaborn.pydata.org
BSD 3-Clause "New" or "Revised" License
12.41k stars 1.91k forks source link

defaults to grid(False) for dotplots using seaborn objects so.Dot #3162

Closed Xparx closed 1 year ago

Xparx commented 1 year ago

Trying to plot with the seaborn objects. Using so.Dot() the following line when commented out reintroduce the grid options. https://github.com/mwaskom/seaborn/blob/master/seaborn/_core/plot.py#L1659

mwaskom commented 1 year ago

I don’t understand.

Xparx commented 1 year ago

Sorry for being unclear. I'm trying to use the new seaborn interface for plotting.

I'm trying to make a Dot plot with grid lines

sns.__version__
'0.12.1'

the problem is i can't get the grid lines to show up even using

if I just use the following code snippet

fig = plt.figure(figsize=figsize, constrained_layout=True, dpi=dpi)
ax = fig.add_subplot(111)
ax.grid(linestyle='--', lw=0.2)
ax.set_axisbelow(True)

p = (
    so.Plot(
        tmp,
        y="y",
        x="x",
        color="p_value", 
        pointsize="Ratio",
    ).add(so.Dot(edgecolor='k')).on(ax).label(x='bla1', y='bla2')
    .scale(color="flare", pointsize=(1, 20))
    .theme({"axes.facecolor": "w", "axes.grid": True, 'axes.axisbelow': True})
)
p

I get an output (using jupyter-notebook) image

I don't get any grid lines, if i comment out the line in plot.py # axis_obj.grid(False, which="both") and use the same code I get image

I have tried a few different combinations of grid commands, but without commenting out the the line I get no grid lines. However if I use

fig = plt.figure(figsize=figsize, constrained_layout=True, dpi=dpi)
ax = fig.add_subplot(111)
ax.grid(linestyle='--', lw=0.2)

p = (
    so.Plot().on(ax)
    .theme({"axes.facecolor": "w", "axes.grid": True, 'axes.axisbelow': True})
)
p

image

I get grid lines even without commenting out the line. Adding data removes the grid lines. (please note I tried to make the code more readable so figure legend is missmatching). I do need to use an external ax.grid command either way.

mwaskom commented 1 year ago

See #3069

Xparx commented 1 year ago

I don't see how the link helps me figure out how to get grid lines. Where should I look for that. Or are you suggesting that they are not available at all?