necoplot
is a matplotlib wrapper.
It may help you to write plotting code briefly.
pip install necoplot
import necoplot as neco
import numpy as np
xx = np.linspace(-5,5,20)
yy = xx*xx
# Basic
with neco.plot() as ax:
ax.plot(xx, yy)
# Config figiure
with neco.plot(figsize=(4,4), dpi=80, facecolor='silver') as ax:
ax.plot(xx, yy)
# Config ax by plot()
with neco.plot(figsize=(6,4), xlim=(-5,0)) as ax:
ax.plot(xx, yy)
# Config ax by using config_ax()
ax0 = neco.config_ax(xlim=(1,5), title='title', xscale='log')
with neco.plot(ax0, figsize=(6,4)) as ax:
ax.plot(xx, yy)
# Config ax directry
with neco.plot() as ax:
ax.plot(xx, yy, label='x squared')
ax.legend()
ax.hlines(y=25, xmin=-5, xmax=5)
# Save figure
with neco.plot() as ax:
ax.plot(xx, yy)
neco.save('sample.png', show=False)
# Plot multiple with mplot()
ax0 = neco.config_ax(121, xlim=(-5, 0),title='Left side')
ax1 = neco.config_ax(122, xlim=(0, 5), title='Right side', yticks=[])
with neco.mplot([ax0, ax1]) as p:
p.axes[0].plot(xx, yy)
p.axes[1].plot(xx, yy)
# Config default values
neco.config_user_parameters(title='New default title!')
with neco.plot() as ax:
ax.plot(xx, yy)
# Reset config
neco.reset()
# Make a simple slope chart
names = ['Apple', 'Banana', 'Cheese', 'Donut', 'Egg']
time0 = [10, 8, 7, 5, 4]
time1 = [8, 11, 4, 2, 3]
with neco.slope() as slope:
slope.plot(time0, time1, names)
# Make another chart which a little more complicated
title = 'Example of a slope chart'
subtitle = 'Food names | Some numbers'
with neco.slope(figsize=(4, 5)) as slope:
slope.highlight({'Banana':'orange'})
slope.config(xstart=0.2, xend=0.9, suffix='%')
slope.plot(time0, time1, names, xticks=('Time0', 'Time1'),
title=title, subtitle=subtitle)