Changing the Dash Spacing?

Hello all,

I would like to make small figures (about 3" wide) so that they are exactly the right size for a LaTeX document I am preparing. This should be straightforward, but I fear I am running into inherent limitations in the matplotlib design.

The particular problem is that the dash spacing for dashed lines seems to be fixed to a certain number of points. This looks fine for default figure sizes, but in a small figure, the dash length becomes comparable to the width of histogram bars I’m producing, so the output just looks like a series of unrelated scribbles rather than a coherent histogram.

I’ve produced a short program below which gives a minimal demonstration of the problem.

Is there some way to change the length of dashes?

Currently, I am hacking together a solution which involves making large figures with huge font sizes, but I would much rather be able to match font sizes exactly by making the figure the right size in the first place.

Many thanks,

Jeff

···

Jeff Klukas, Physics
University of Wisconsin
http://jeff.klukas.net


import matplotlib.pyplot as plt

fig = plt.figure(figsize=(6,4))

plt.plot(range(20), range(20), linestyle=‘steps–’)

plt.savefig(‘dashdemo’)

fig = plt.figure(figsize=(3,2))

plt.plot(range(20), range(20), linestyle=‘steps–’)

plt.savefig(‘dashdemosmall’)

Hello all,

I would like to make small figures (about 3" wide) so that they are
exactly the right size for a LaTeX document I am preparing. This should
be straightforward, but I fear I am running into inherent limitations in
the matplotlib design.

The particular problem is that the dash spacing for dashed lines seems
to be fixed to a certain number of points. This looks fine for default
figure sizes, but in a small figure, the dash length becomes comparable
to the width of histogram bars I'm producing, so the output just looks
like a series of unrelated scribbles rather than a coherent histogram.

I've produced a short program below which gives a minimal demonstration
of the problem.

Is there some way to change the length of dashes?

Currently, I am hacking together a solution which involves making large
figures with huge font sizes, but I would much rather be able to match
font sizes exactly by making the figure the right size in the first place.

Many thanks,
Jeff

>> Jeff Klukas, Physics
>> University of Wisconsin
>> http://jeff.klukas.net

-------------------------------------
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(6,4))

line, = plt.plot(range(20), range(20), linestyle='steps--')
line.set_dashes((3,2)) # or whatever on/off sequence in points you want

Eric

···

On 02/23/2012 10:46 AM, Jeff Klukas wrote:

plt.savefig('dashdemo')

fig = plt.figure(figsize=(3,2))
plt.plot(range(20), range(20), linestyle='steps--')
plt.savefig('dashdemosmall')

------------------------------------------------------------------------------
Virtualization& Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users