linestyles in matplotlib.pyplot.plot

413 views
Skip to first unread message

Goutam Paul

unread,
Sep 12, 2012, 3:11:34 PM9/12/12
to sage-...@googlegroups.com
It seems that there are only five line-styles:

"-" (solid) – default
"--" (dashed)
"-." (dash dot)
":" (dotted)
"None" or " " or "" (nothing)

What if I want to have more linestyles? Say, ++, **, xx, ~~, etc.
Is it possible to have user-defined linestyles? How?

kcrisman

unread,
Sep 12, 2012, 3:14:38 PM9/12/12
to sage-...@googlegroups.com
Are you saying that matplotlib upgrades have made more available, or that matplotlib should implement more?

1) If they're available in the mpl in Sage, you might even be able to use them now.

2) If you want new mpl capability, email their list.

3) If you want the same linestyle but with a different marker, try the "marker" option (I think that's what it's called).  There are a lot of options for that.

- kcrisman 

Goutam Paul

unread,
Sep 12, 2012, 5:41:14 PM9/12/12
to sage-...@googlegroups.com
I want to know the syntax for user-defined linestyles, like ++, **, etc.

I tried with the marker option - but it did not work with matplotlib.pyplot.ploy
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To post to this group, send email to sage-...@googlegroups.com.
> To unsubscribe from this group, send email to
> sage-devel+...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-devel?hl=en.
>

Jason Grout

unread,
Sep 12, 2012, 6:07:47 PM9/12/12
to sage-...@googlegroups.com
On 9/12/12 2:11 PM, Goutam Paul wrote:
> It seems that there are only five line-styles:
>
> "-" (solid) � default
> "--" (dashed)
> "-." (dash dot)
> ":" (dotted)
> "None" or " " or "" (nothing)
>
> What if I want to have more linestyles? Say, ++, **, xx, ~~, etc.
> Is it possible to have user-defined linestyles? How?

Those styles are hardcoded in matplotlib:
http://matplotlib.org/api/artist_api.html?highlight=linestyle#matplotlib.lines.Line2D.set_linestyle

I'm not sure if there is a way to specify a custom dash pattern (like
http://reference.wolfram.com/mathematica/ref/Dashing.html, for example).
That would be a good question for the matplotlib mailing list:
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Thanks,

Jason



Goutam Paul

unread,
Sep 13, 2012, 9:11:25 AM9/13/12
to sage-...@googlegroups.com
Can we use the markers as alternatives for linestyles?
Consider the following in sage:

Suppose I have defined f(x) for a range already, say by the following:

x = np.arange(0,1,0.001)

import matplotlib.pyplot as plt

plt.plot(x,f(x), color='magenta', linestyle='--', linewidth=4, label="$f(x)$")

I want to know the equivalent syntax for '++' marker for the same plot of f(x) against (x).

On Thu, Sep 13, 2012 at 12:07 AM, Jason Grout <jason...@creativetrax.com> wrote:
On 9/12/12 2:11 PM, Goutam Paul wrote:
It seems that there are only five line-styles:

"-" (solid) – default

"--" (dashed)
"-." (dash dot)
":" (dotted)
"None" or " " or "" (nothing)

What if I want to have more linestyles? Say, ++, **, xx, ~~, etc.
Is it possible to have user-defined linestyles? How?

Jason Grout

unread,
Sep 13, 2012, 9:20:03 AM9/13/12
to sage-...@googlegroups.com
On 9/13/12 8:11 AM, Goutam Paul wrote:
> Can we use the markers as alternatives for linestyles?
> Consider the following in sage:
>
> Suppose I have defined f(x) for a range already, say by the following:
>
> x = np.arange(0,1,0.001)
>
> import matplotlib.pyplot as plt
>
> plt.plot(x,f(x), color='magenta', linestyle='--', linewidth=4,
> label="$f(x)$")
>
> I want to know the equivalent syntax for '++' marker for the same plot
> of f(x) against (x).


We don't offer any other capabilities for this beyond what is built into
matplotlib (in fact, the code above uses numpy and matplotlib directly,
so there is no Sage involved). So I think the conversation you started
on the matplotlib list is the one to look at.

Thanks,

Jason


Goutam Paul

unread,
Sep 13, 2012, 9:26:27 AM9/13/12
to sage-...@googlegroups.com
Dear Jason,

Thanks. I would continue the discussion in matplotlib forum.

Regards,
Goutam.



Thanks,

Jason


--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To post to this group, send email to sage-...@googlegroups.com.
To unsubscribe from this group, send email to sage-devel+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages