-
Notifications
You must be signed in to change notification settings - Fork 103
indicate_error for x direction #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Added this as part of a giant refactor. Here's the massive new website example showcasing this: import proplot as plot
import numpy as np
import pandas as pd
# Sample data
state = np.random.RandomState(51423)
data = state.rand(20, 8).cumsum(axis=0).cumsum(axis=1)[:, ::-1]
data = data + 20 * state.normal(size=(20, 8)) + 30
data = pd.DataFrame(data, columns=np.arange(0, 16, 2))
data.columns.name = 'column number'
data.name = 'variable'
# Loop through "vertical" and "horizontal" versions
array_vertical = [[1], [2], [3]]
array_horizontal = [[1, 1], [2, 3], [2, 3]]
for name, array in zip(('horizontal', 'vertical'), (array_horizontal, array_vertical)):
# Figure
fig, axs = plot.subplots(
array, refaspect=1.5, refwidth=4,
share=0, hratios=(2, 1, 1)
)
axs.format(abc=True, suptitle=f'Indicating {name} error bounds')
# Medians and percentile ranges
ax = axs[0]
kw = dict(
color='light red', legend=True,
median=True, barpctile=90, boxpctile=True,
# median=True, barpctile=(5, 95), boxpctile=(25, 75) # equivalent
)
if name == 'horizontal':
ax.barh(data, **kw)
else:
ax.bar(data, **kw)
ax.format(title='Bar plot')
# Means and standard deviation range
ax = axs[1]
kw = dict(
color='denim', marker='x', markersize=8**2, linewidth=0.8,
label='mean', shadelabel=True,
mean=True, shadestd=1,
# mean=True, shadestd=(-1, 1) # equivalent
)
if name == 'horizontal':
ax.scatterx(data, legend='b', legend_kw={'ncol': 1}, **kw)
else:
ax.scatter(data, legend='ll', **kw)
ax.format(title='Marker plot')
# User-defined error bars
ax = axs[2]
means = data.mean(axis=0)
means.name = data.name
shadedata = np.percentile(data, (25, 75), axis=0) # dark shading
fadedata = np.percentile(data, (5, 95), axis=0) # light shading
method = ax.plotx if name == 'horizontal' else ax.plot
kw = dict(
shadedata=shadedata, fadedata=fadedata,
label='mean', shadelabel='50% CI', fadelabel='90% CI',
color='ocean blue', barzorder=0, boxmarker=False,
)
if name == 'horizontal':
ax.plotx(means, legend='b', legend_kw={'ncol': 1}, **kw)
else:
ax.plot(means, legend='ll', **kw)
ax.format(title='Line plot') |
I went about this by adding |
Uh oh!
There was an error while loading. Please reload this page.
Description
It would be really nice if
indicate_error
can also show error bars in x direction.Steps to reproduce
Equivalent steps in matplotlib
errorbar
has thexerr
option to do thisThe text was updated successfully, but these errors were encountered: