I have a code block that produces a 3d graph
ax = plt.axes(projection = '3d')
ax.plot3D(outputs_real, outputs_imaginary, inputs)
ax.set_xlabel('Real Component')
ax.set_ylabel('Imaginary Component')
ax.set_zlabel('Inputs')
plt.show()
and a second code block that makes a 2d graph using 2 of the above's axes.
ax2 = plt.plot(outputs_real, outputs_imaginary)
ax2.set_xlabel('Real Component')
ax2.set_ylabel('Imaginary Component')
But for some reason when I try to plot the second one I'll get this error
AttributeError: 'list' object has no attribute 'set_xlabel'
and the second graph will map onto the first like this:
I want the two graphs to be separate
Details:
- This is being done in a Jupyter notebook
- outputs_real, outputs_imaginary, and inputs are all lists
CodePudding user response:
CodePudding user response:
One option is to create a new figure. After you have called the first plt.show()
create a new figure and ax with
plt.figure(2)
ax2 = plt.axes()
You can also plot the two figures simultaneously if you want, by not calling the first plt.show()
and only calling plt.show()
after creating both of the figures.