Unrecognized linestyle

690 views
Skip to first unread message

cesarnda

unread,
Aug 3, 2009, 4:46:14 PM8/3/09
to sage-support
what is wrong with the following:

sage: v1 = vector([1,2])
sage: v2 = vector([2,1])
sage: p1 = plot(v1, rgbcolor=(1,0,0))
sage: p2 = plot(v2, rgbcolor=(0,1,0))
sage: t1 = text("V1", (1,2.1), rgbcolor=(1,0,0))
sage: t2 = text("V2", (2,1.1), rgbcolor=(0,1,0))
sage: p3 = plot(v1 + v2, rgbcolor=(0,0,1))
sage: t3 = text("V1 + V2", v1+v2 + vector([0,0.1]), rgbcolor=(0,0,1))
sage: p4 = plot(vector([3,3]), rgbcolor=(1,1,1), linestyle='--')
sage: show(p1 + p2 + p3 + p4 + t1 + t2 + t3, xmin=-0.5, xmax=3.5,
ymin=-0.5, ymax=3.5)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/cesarnda/.sage/sage_notebook/worksheets/admin/9/code/
120.py", line 7, in <module>
show(p1 + p2 + p3 + p4 + t1 + t2 + t3, xmin=-_sage_const_0p5 ,
xmax=_sage_const_3p5 , ymin=-_sage_const_0p5 , ymax=_sage_const_3p5 )
File "", line 1, in <module>

File "/Users/cesarnda/Software/sage/local/lib/python2.6/site-
packages/sage/misc/functional.py", line 952, in show
return x.show(*args, **kwds)
File "/Users/cesarnda/Software/sage/local/lib/python2.6/site-
packages/sage/plot/plot.py", line 1302, in show
hgridlinesstyle=hgridlinesstyle)
File "/Users/cesarnda/Software/sage/local/lib/python2.6/site-
packages/sage/plot/plot.py", line 1627, in save
canvas.print_figure(filename, dpi=dpi)
File "/Users/cesarnda/Software/sage/local/lib/python2.6/site-
packages/matplotlib/backend_bases.py", line 1453, in print_figure
**kwargs)
File "/Users/cesarnda/Software/sage/local/lib/python2.6/site-
packages/matplotlib/backends/backend_agg.py", line 326, in print_png
FigureCanvasAgg.draw(self)
File "/Users/cesarnda/Software/sage/local/lib/python2.6/site-
packages/matplotlib/backends/backend_agg.py", line 282, in draw
self.figure.draw(self.renderer)
File "/Users/cesarnda/Software/sage/local/lib/python2.6/site-
packages/matplotlib/figure.py", line 773, in draw
for a in self.axes: a.draw(renderer)
File "/Users/cesarnda/Software/sage/local/lib/python2.6/site-
packages/matplotlib/axes.py", line 1668, in draw
a.draw(renderer)
File "/Users/cesarnda/Software/sage/local/lib/python2.6/site-
packages/matplotlib/patches.py", line 3588, in draw
gc.set_linestyle(self._linestyle)
File "/Users/cesarnda/Software/sage/local/lib/python2.6/site-
packages/matplotlib/backend_bases.py", line 650, in set_linestyle
raise ValueError('Unrecognized linestyle: %s' % style)
ValueError: Unrecognized linestyle: --

Why does it say that the linestyle='--' is not recognized?

Rado

unread,
Aug 3, 2009, 9:49:17 PM8/3/09
to sage-support
try using 'dashed' instead of '--'. Works for me.

I have no idea why '--' works for plotting lines but not vectors
(which are arrows) ...

Rado

Tobias Weich

unread,
Mar 27, 2013, 5:21:18 AM3/27/13
to sage-s...@googlegroups.com
I came across the same issue with arc in sage 5.8

line([(0,1),(1,1)],linestyle=':')

works fine, however

arc((0,0),1,sector=(0,pi),linestyle=':')

raises the "unknown linestyle" error and linestyle='dotted' works for both.

Is there a deeper reason why these matplotlib linestyle shorts do not work for all plot methods or wouldn't it be quite easy fix this and make this more consistent?

Tobias

P Purkayastha

unread,
Mar 27, 2013, 7:39:50 AM3/27/13
to sage-s...@googlegroups.com
On 03/27/2013 05:21 PM, Tobias Weich wrote:
> I came across the same issue with arc in sage 5.8
>
> |
> line([(0,1),(1,1)],linestyle=':')
> |
>
> works fine, however
>
> |
> arc((0,0),1,sector=(0,pi),linestyle=':')
> |
>
> raises the "unknown linestyle" error and linestyle='dotted' works for both.
>
> Is there a deeper reason why these matplotlib linestyle shorts do not
> work for all plot methods or wouldn't it be quite easy fix this and make
> this more consistent?
>
> Tobias

Yes, the fix is easy but extensive. Relevant are the tickets

http://trac.sagemath.org/sage_trac/ticket/13834
http://trac.sagemath.org/sage_trac/ticket/13828

and the other tickets mentioned in them. You are welcome to try to fix
#13834 :)


Reply all
Reply to author
Forward
0 new messages