-
Notifications
You must be signed in to change notification settings - Fork 361
Closed as not planned
Closed as not planned
Copy link
Labels
bugSomething isn't workingSomething isn't working
Description
import matplotlib.pyplot
from fractions import Fraction
from itertools import chain
data = {
"3d6": {3: Fraction(1, 216), 4: Fraction(1, 72), 5: Fraction(1, 36), 6: Fraction(5, 108), 7: Fraction(5, 72), 8: Fraction(7, 72), 9: Fraction(25, 216), 10: Fraction(1, 8), 11: Fraction(1, 8), 12: Fraction(25, 216), 13: Fraction(7, 72), 14: Fraction(5, 72), 15: Fraction(5, 108), 16: Fraction(1, 36), 17: Fraction(1, 72), 18: Fraction(1, 216)},
"2d10": {2: Fraction(1, 100), 3: Fraction(1, 50), 4: Fraction(3, 100), 5: Fraction(1, 25), 6: Fraction(1, 20), 7: Fraction(3, 50), 8: Fraction(7, 100), 9: Fraction(2, 25), 10: Fraction(9, 100), 11: Fraction(1, 10), 12: Fraction(9, 100), 13: Fraction(2, 25), 14: Fraction(7, 100), 15: Fraction(3, 50), 16: Fraction(1, 20), 17: Fraction(1, 25), 18: Fraction(3, 100), 19: Fraction(1, 50), 20: Fraction(1, 100)},
"d8d12": {2: Fraction(1, 96), 3: Fraction(1, 48), 4: Fraction(1, 32), 5: Fraction(1, 24), 6: Fraction(5, 96), 7: Fraction(1, 16), 8: Fraction(7, 96), 9: Fraction(1, 12), 10: Fraction(1, 12), 11: Fraction(1, 12), 12: Fraction(1, 12), 13: Fraction(1, 12), 14: Fraction(7, 96), 15: Fraction(1, 16), 16: Fraction(5, 96), 17: Fraction(1, 24), 18: Fraction(1, 32), 19: Fraction(1, 48), 20: Fraction(1, 96)}
}
with matplotlib.style.context("bmh"):
fig = matplotlib.pyplot.figure()
xmin, ymin, dx, dy = 0.0, 0.0, 1.0, 1.0 # 0.1, 0.1, 0.9, 0.9
ax = fig.add_axes((xmin, ymin, dx, dy))
ax.yaxis.set_major_formatter(matplotlib.ticker.PercentFormatter(xmax=1))
unique_outcomes = sorted(set(chain.from_iterable(data.values())))
ax.set_xticks(unique_outcomes)
ax.set_xlim((min(unique_outcomes) - 0.5, max(unique_outcomes) + 0.5))
for label, d in data.items():
outcomes, values = zip(*((outcome, float(value)) for outcome, value in d.items()))
ax.plot(
outcomes, values,
label=label,
marker="o",
)
matplotlib.pyplot.show()
print(matplotlib.__version__)
Jupyter Lab (using matplotlib
3.5.2):
Jupyter Lite (0.1.0b14 using matplotlib
3.5.2):
In this particular case, you can achieve a much closer (but still different) result by doing this instead:
xmin, ymin, dx, dy = 0.1, 0.1, 0.9, 0.9
However, this isn't universally true. Subplots for example are radically different with Jupyter Lite's rendering tending to pad with whitespace proportionate to the number of subplots, which is weird. Here's one example of the same code being rendered by the two platforms:
I have compared matplotlib.rcParams
on both platforms and found that the only difference is {..., "backend": "agg", ...}
on Jupyter Lite, which I don't think is determinative.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working