Skip to content
Snippets Groups Projects

Draft: Resolve "Deserialize subplots"

Closed Wu, Yali requested to merge 12-deserialize-subplots into main
2 files
+ 18
18
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -25,6 +25,9 @@ class Deserializer:
p.axes = []
for a in d["axes"]:
axis = Axis()
axis.xlabel = a["xlabel"]
axis.ylabel = a["ylabel"]
axis.title = a['title']
axis.traces = []
for t in a["traces"]:
plotted_element = Trace()
@@ -47,9 +50,16 @@ class Deserializer:
matplotlib.pyplot.Figure: matplotlib.pyplot.Figure created from the JSON file
"""
self.plot = self.from_json(json_file)
fig = plt.figure()
for axis in self.plot.axes:
ax = fig.add_subplot()
axes_list = self.plot.axes
fig, ax = plt.subplots(len(axes_list))
print(ax)
for axis in axes_list:
index = axes_list.index(axis)
ax[index].set_title(axis.title)
ax[index].set_xlabel(axis.xlabel)
ax[index].set_ylabel(axis.ylabel)
for t in axis.traces:
ax.plot(t.xdata, t.ydata, label=t.label, color=t.color)
ax[index].plot(t.xdata, t.ydata, label=t.label, color=t.color)
ax[index].legend()
fig.tight_layout()
return fig
Loading