-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support for subplots #39
Comments
Hi,
import matplotlib.pyplot as plt
import matplotx
import numpy as np
# create data
rng = np.random.default_rng(0)
offsets = [1.0, 1.50, 1.60]
labels = ["no balancing", "CRV-27", "CRV-27*"]
x0 = np.linspace(0.0, 3.0, 100)
y = [offset * x0 / (x0 + 1) + 0.1 * rng.random(len(x0)) for offset in offsets]
fig, axes = plt.subplots(2, 1) # add subplots
for ax in axes: # Let's make two identical subplots
plt.sca(ax)
with plt.style.context(matplotx.styles.dufte):
for yy, label in zip(y, labels):
ax.plot(x0, yy, label=label) # changed plt. to ax.
ax.set_xlabel("distance [m]") # changed plt. to ax.
matplotx.ylabel_top("voltage [V]") # move ylabel to the top, rotate
matplotx.line_labels() # line labels to the right
plt.show()
import matplotlib.pyplot as plt
import matplotx
import numpy as np
# create data
rng = np.random.default_rng(0)
offsets = [1.0, 1.50, 1.60]
labels = ["no balancing", "CRV-27", "CRV-27*"]
x0 = np.linspace(0.0, 3.0, 100)
y = [offset * x0 / (x0 + 1) + 0.1 * rng.random(len(x0)) for offset in offsets]
fig, axes = plt.subplots(2, 1) # add subplots
for ax in axes: # Let's make two identical subplots
with plt.style.context(matplotx.styles.dufte):
for yy, label in zip(y, labels):
ax.plot(x0, yy, label=label) # changed plt. to ax.
ax.set_xlabel("distance [m]") # changed plt. to ax.
matplotx.ylabel_top("voltage [V]") # move ylabel to the top, rotate
matplotx.line_labels(ax) # line labels to the right
plt.show() For some reason option 2 doesn't work. @nschloe any idea? |
Hi, please see the Pull Request that I submitted for this. Thanks for the response! |
Closed
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Perhaps this is already implemented and I'm just unable to find it. I think this package in general is great; very easy to use and very beautiful. Thank you for your time making it.
I'm unable to get
matplotx
working properly when using subplots. Adapting theClean line plots (dufte)
example to include two subplots (side-by-side, or one-below-the-other) appears not to work.The text was updated successfully, but these errors were encountered: