proplot-dev / proplot

🎨 A succinct matplotlib wrapper for making beautiful, publication-quality graphics
https://proplot.readthedocs.io
MIT License
1.07k stars 96 forks source link

Unable to use xmargin for line and area plots #376

Open AWSisco opened 1 year ago

AWSisco commented 1 year ago

Description

I like the default "sticky" behavior of the x bounds in line and area plots but have found that I can't override that behavior with xmargin when I want to.

Steps to reproduce

import proplot as pplt

x = pplt.arange(0,1,0.1)
z = pplt.arange(1,2,0.1)

fig, ax = pplt.subplots(aspect=(2,1))

ax.plot(x,3**(z),c='blurple')
ax.plot(x,6**(z),c='yellow6')

ax.area(x,2**(z),4**(z),color='blurple',alpha=0.2,lw=0)
ax.area(x,5**(z),7**(z),color='yellow6',alpha=0.2,lw=0)

ax.format(xmargin=0.2, xlocator=0.2) #xmargin has no effect here

sticky

Expected behavior:

Setting xmargin=0.2 should expand my x axis range to −0.2 to 1.2. However, setting xmargin has no effect. Since "sticky" bounds are not enforced for scatter plots, the desired xmargin can be shown with ax.scatter.

fig, ax = pplt.subplots(aspect=(2,1))

ax.scatter(x,3**(z),c='blurple',s=15)
ax.scatter(x,6**(z),c='yellow6',s=15)

ax.format(xmargin=0.2, xlocator=0.2) #This produces the desired x axis range

sticky_scatter

Actual behavior:

See first example.

Proplot version

proplot=0.9.5.post284 matplotlib=3.4.3