Skip to content

How to plot discrete point with matplotlib? #1682

Discussion options

You must be logged in to vote

When you do ax.plot([vc,vc],[pb,pc]), Matplotlib is going to try to convert [ 0.05 * ureg.L, 0.05 * ureg.L] and [2 * ureg.MPa, 7 * ureg.MPa] to arrays, which is not going to do what you want (at best it will result in an array of objects). You want to create a single array to pass to plot, as you did on the line above. One way to do that would be:

ax.plot([vc.m, vc.m] * vc.units, [pb.m, pc.m_as(pb.units)] * pb.units)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@keewis
Comment options

@YanXingYu-star
Comment options

Answer selected by YanXingYu-star
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants