Skip to content

Commit e3217d7

Browse files
committed
Update docs
1 parent aedd877 commit e3217d7

File tree

3 files changed

+23
-27
lines changed

3 files changed

+23
-27
lines changed

docs/1dplots.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@
205205
import numpy as np
206206
import pandas as pd
207207
plot.rc['title.loc'] = 'uc'
208-
plot.rc['axes.ymargin'] = plot.rc['axes.xmargin'] = 0.05
209208
state = np.random.RandomState(51423)
210209
data = (
211210
state.rand(20, 8).cumsum(axis=0).cumsum(axis=1)[:, ::-1]
@@ -258,9 +257,10 @@
258257
# `~proplot.axes.cycle_changer`, and `~proplot.axes.standardize_1d`.
259258
# You can now *group* or *stack* columns of data by passing 2D arrays to
260259
# `~matplotlib.axes.Axes.bar` or `~matplotlib.axes.Axes.barh`, just like in
261-
# `pandas`. Also, `~matplotlib.axes.Axes.bar` and `~matplotlib.axes.Axes.barh`
262-
# now employ "default" *x* coordinates if you failed to provide them
263-
# explicitly, just like `~matplotlib.axes.Axes.plot`.
260+
# `pandas`, or use different colors for negative and positive bars by
261+
# passing ``negpos=True``. Also, `~matplotlib.axes.Axes.bar` and
262+
# `~matplotlib.axes.Axes.barh` now employ "default" *x* coordinates if you
263+
# failed to provide them explicitly.
264264
#
265265
# To make filled "area" plots, use the new `~proplot.axes.Axes.area` and
266266
# `~proplot.axes.Axes.areax` methods. These are alises for
@@ -270,7 +270,7 @@
270270
# `~proplot.axes.fill_betweenx_wrapper`. You can now *stack* or *overlay*
271271
# columns of data by passing 2D arrays to `~proplot.axes.Axes.area` and
272272
# `~proplot.axes.Axes.areax`, just like in `pandas`. You can also now draw
273-
# area plots that *change color* when the fill boundaries cross each other by
273+
# area plots that change color when the fill boundaries cross each other by
274274
# passing ``negpos=True`` to `~matplotlib.axes.Axes.fill_between`. The most
275275
# common use case for this is highlighting negative and positive areas with
276276
# different colors, as shown below.
@@ -313,33 +313,39 @@
313313
# %%
314314
import proplot as plot
315315
import numpy as np
316-
plot.rc.margin = 0
317-
fig, axs = plot.subplots(array=[[1, 2], [3, 3]], hratios=(1, 0.8), share=0)
318-
axs.format(xlabel='xlabel', ylabel='ylabel', suptitle='Area plot demo')
316+
fig, axs = plot.subplots(array=[[1, 2], [3, 3]], hratios=(1, 1.5), share=0)
317+
axs.format(grid=False, xlabel='xlabel', ylabel='ylabel', suptitle='Area plot demo')
319318
state = np.random.RandomState(51423)
320319
data = state.rand(5, 3).cumsum(axis=0)
321320
cycle = ('gray3', 'gray5', 'gray7')
322321

323-
# Overlaid and stacked area patches
322+
# Overlaid area patches
324323
ax = axs[0]
325324
ax.area(
326-
np.arange(5), data, data + state.rand(5)[:, None], cycle=cycle, alpha=0.5,
325+
np.arange(5), data, data + state.rand(5)[:, None], cycle=cycle, alpha=0.7,
327326
legend='uc', legend_kw={'center': True, 'ncols': 2, 'labels': ['z', 'y', 'qqqq']},
328327
)
329328
ax.format(title='Fill between columns')
329+
330+
# Stacked area patches
330331
ax = axs[1]
331332
ax.area(
332333
np.arange(5), data, stacked=True, cycle=cycle, alpha=0.8,
333334
legend='ul', legend_kw={'center': True, 'ncols': 2, 'labels': ['z', 'y', 'qqqq']},
334335
)
335336
ax.format(title='Stack between columns')
336337

337-
# Positive and negative color area patches
338+
# Positive and negative color bars and area patches
338339
ax = axs[2]
339-
data = 5 * (state.rand(20) - 0.5)
340-
ax.area(data, negpos=True, negcolor='blue7', poscolor='red7')
341-
ax.format(title='Positive and negative colors', xlabel='xlabel', ylabel='ylabel')
342-
axs.format(grid=False)
340+
data = 4 * (state.rand(20) - 0.5)
341+
ax.bar(data, bottom=-2, width=1, edgecolor='none', negpos=True)
342+
ax.area(data + 2, y2=2, negpos=True)
343+
for offset in (-2, 2):
344+
ax.axhline(offset, color='k', linewidth=1, linestyle='--')
345+
ax.format(
346+
xmargin=0, xlabel='xlabel', ylabel='ylabel',
347+
title='Positive and negative colors demo', titleweight='bold',
348+
)
343349
plot.rc.reset()
344350

345351

@@ -369,10 +375,7 @@
369375
data,
370376
columns=pd.Index(['a', 'b', 'c', 'd', 'e'], name='xlabel')
371377
)
372-
axs.format(
373-
ymargin=0.1, xmargin=0.1, grid=False,
374-
suptitle='Boxes and violins demo'
375-
)
378+
axs.format(grid=False, suptitle='Boxes and violins demo')
376379

377380
# Box plots
378381
ax = axs[0]
@@ -428,7 +431,6 @@
428431
x, y, c, cmap=cmap, lw=7, interp=5, capstyle='round', joinstyle='round'
429432
)
430433
ax.format(xlabel='xlabel', ylabel='ylabel', title='Line with smooth gradations')
431-
ax.format(xmargin=0.05, ymargin=0.05)
432434
ax.colorbar(m, loc='b', label='parametric coordinate', locator=5)
433435

434436
# Parametric line with stepped gradations

docs/basics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
xlabel='x-axis', ylabel='y-axis',
201201
xscale='log',
202202
xlim=(1, 10), xticks=1,
203-
ylim=(-2, 2), yticks=plot.arange(-2, 2),
203+
ymargin=0.05, yticks=plot.arange(-2, 2),
204204
yticklabels=('a', 'bb', 'c', 'dd', 'e'),
205205
ytickloc='both', yticklabelloc='both',
206206
xtickdir='inout', xtickminor=False, ygridminor=True,

docs/projections.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,6 @@
220220
fig.colorbar(m, loc='b', span=i + 1, label='values', extendsize='1.7em')
221221
else:
222222
ax.pcolor(lon, lat, data, cmap=cmap, globe=globe, extend='both')
223-
if globe:
224-
continue
225-
xi = offset + np.linspace(0, 360, 20)
226-
for cmd in (np.sin, np.cos):
227-
yi = cmd(xi * np.pi / 180) * 60
228-
ax.plot(xi, yi, color='k', lw=0, marker='o')
229223
axs.format(
230224
suptitle=titles[globe],
231225
collabels=['Cartopy example', 'Basemap example'],

0 commit comments

Comments
 (0)