Text of discourse.matplotlib.org › t › help-with-matplotlib-path-class › 10111 as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

help with matplotlib.path class - matplotlib-users - Matplotlib

help with matplotlib.path class Community matplotlib-users _Amitava_Maity October 30, 2008, 5:02pm 1 Thanks, Being a novice, I am trying the first thing in the example gallery that caught my eye. Vlines does seem to be a better option. But what's puzzling me is why do I get just a plot of the axes with the following code? Where are the vertical lines that I am looking for? from matplotlib import path from matplotlib import patches from matplotlib import pyplot as plt codes = (1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2) vertices = ((39525.540000000001, 144.91), (39525.540000000001, 161.352), (39874.5, 149.5), (39874.5, 166.142), (40205.0, 150.41), (40205.0, 167.05199999999999), (40518.449999999997, 149.36000000000001), (40518.449999999997, 166.00200000000001), (40828.0, 148.50999999999999), (40828.0, 165.15199999999999), (41173.239999999998, 151.16), (41173.239999999998, 167.602), (41510.0, 150.09), (41510.0, 166.732), (41858.0, 146.25), (41858.0, 162.892), (42158.0, 152.63999999999999), (42158.0, 169.28199999999998), (42486.889999999999, 155.22999999999999), (42486.889999999999, 171.672)) patch = patches.PathPatch(path.Path(vertices, codes)) plt.gca().add_patch(patch) plt.show() If your first tuple is "codes", and second is "vertices", You can do: from matplotlib import path from matplotlib import patches from matplotlib import pyplot as plt patch = patches.PathPatch(path.Path(vertices, codes)) plt.gca().add_patch(patch) plt.show() However... rather than going through all that, have you considered using vlines?

That will save you the trouble of generating all the data in that format yourself. http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pypl ot.vlines Cheers, Mike Amitava Maity wrote: Hello list, I have generated the following tuples: (1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2) ((39525.540000000001, 144.91), (39525.540000000001, 161.352), (39874.5, 149.5), (39874.5, 166.142), (40205.0, 150.41), (40205.0, 167.05199999999999), (40518.449999999997, 149.36000000000001), (40518.449999999997, 166.00200000000001), (40828.0, 148.50999999999999), (40828.0, 165.15199999999999), (41173.239999999998, 151.16), (41173.239999999998, 167.602), (41510.0, ··· On Thu, 30 Oct 2008 Michael Droettboom wrote : 150.09), (41510.0, 166.732), (41858.0, 146.25), (41858.0, 162.892), (42158.0, 152.63999999999999), (42158.0, 169.28199999999998), (42486.889999999999, 155.22999999999999), (42486.889999999999, 171.672)) How do I use the Matplotlib.path class to draw a set of disconnected vertical lines?

Thanks in advance, AMaity. -------------------------------------------------------------------- ----- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-users mailing list [email protected] matplotlib-users List Signup and Options -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA Michael_Droettboom1 October 30, 2008, 5:04pm 2 The limits don't get automatically adjusted when using add_patch().

You could do something like: plt.gca().set_xlim(min([x for x, y in vertices]), max([x for x, y in vertices])) plt.gca().set_ylim(min([y for x, y in vertices]), max([y for x, y in vertices])) Again, vlines will do all this for you. Mike Amitava Maity wrote: ··· Thanks, Being a novice, I am trying the first thing in the example gallery that caught my eye. Vlines does seem to be a better option. But what's puzzling me is why do I get just a plot of the axes with the following code?

Where are the vertical lines that I am looking for? from matplotlib import path from matplotlib import patches from matplotlib import pyplot as plt codes = (1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2) vertices = ((39525.540000000001, 144.91), (39525.540000000001, 161.352), (39874.5, 149.5), (39874.5, 166.142), (40205.0, 150.41), (40205.0, 167.05199999999999), (40518.449999999997, 149.36000000000001), (40518.449999999997, 166.00200000000001), (40828.0, 148.50999999999999), (40828.0, 165.15199999999999), (41173.239999999998, 151.16), (41173.239999999998, 167.602), (41510.0, 150.09), (41510.0, 166.732), (41858.0, 146.25), (41858.0, 162.892), (42158.0, 152.63999999999999), (42158.0, 169.28199999999998), (42486.889999999999, 155.22999999999999), (42486.889999999999, 171.672)) patch = patches.PathPatch(path.Path(vertices, codes)) plt.gca().add_patch(patch) plt.show() On Thu, 30 Oct 2008 Michael Droettboom wrote : If your first tuple is "codes", and second is "vertices", You can do: from matplotlib import path from matplotlib import patches from matplotlib import pyplot as plt patch = patches.PathPatch(path.Path(vertices, codes)) plt.gca().add_patch(patch) plt.show() However... rather than going through all that, have you considered using vlines?

That will save you the trouble of generating all the data in that format yourself. http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pypl ot.vlines Cheers, Mike Amitava Maity wrote: Hello list, I have generated the following tuples: (1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2) ((39525.540000000001, 144.91), (39525.540000000001, 161.352), (39874.5, 149.5), (39874.5, 166.142), (40205.0, 150.41), (40205.0, 167.05199999999999), (40518.449999999997, 149.36000000000001), (40518.449999999997, 166.00200000000001), (40828.0, 148.50999999999999), (40828.0, 165.15199999999999), (41173.239999999998, 151.16), (41173.239999999998, 167.602), (41510.0, 150.09), (41510.0, 166.732), (41858.0, 146.25), (41858.0, 162.892), (42158.0, 152.63999999999999), (42158.0, 169.28199999999998), (42486.889999999999, 155.22999999999999), (42486.889999999999, 171.672)) How do I use the Matplotlib.path class to draw a set of disconnected vertical lines?

Thanks in advance, AMaity. -------------------------------------------------------------------- ----- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-users mailing list [email protected] matplotlib-users List Signup and Options -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-users mailing list [email protected] matplotlib-users List Signup and Options -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA