I have the next problem. I had an datafile like;
1412481600,304,0,0,0,304,0
1412485200,385,0,0,0,383,0
1412488800,332,0,0,0,331,0
1412492400,359,0,0,0,355,0
I have changed the format to;
08-11-2014-17:00,390,0,27,417
08-11-2014-18:00,474,0,0,474
08-11-2014-19:00,467,0,0,467
08-11-2014-20:00,687,0,0,687
I changed either the gnuplotscript.
First was;
set timefmt x "%s"
To now in;
set timefmt x "%d-%m-%Y-%H:%M"
In the new situation gnuplot gives me 2 columns they are overwrite
with other columns.
What am I doing wrong or I forget ?
Here the working en wrong example;
And this is the complete code;
file = 'uur.txt'
set output "dag.png"
set datafile separator ","
set linestyle 1 lt 1 lc rgb "black"
set bmargin 5 # witruimte onder grafiek
set boxwidth 600 absolute
set style boxplot
set border back
dy=500 # zie y waarde terminal
# Hier worden de maximale en minimale y-waarden van gnuplot bepaald.
set terminal unknown
plot "<tail -24 ".file."" using :(-$5) w p, '' u :4 w p
ymax= GPVAL_Y_MAX
ymin= GPVAL_Y_MIN
ptmax=ymax*dy/(ymax-ymin)
ptmin=ymin*dy/(ymax-ymin)
replot
set terminal pngcairo truecolor enhanced size 1200, 500 font "Courier Bold,10" background rgb "#CFCFFF"
stats "<tail -24 ".file."" using 2:3 nooutput
afnt = STATS_sum_x
gelt = STATS_sum_y
afn = afnt/24
gel = gelt/24
stats "< tail -24 ".file."" using 4:5 nooutput
zon = STATS_max_x
zont = STATS_sum_x
geb = STATS_max_y
gebt = STATS_sum_y
zonavg = STATS_sum_x/24
gebavg = STATS_sum_y/24
stats "<tail -1 ".file."" using (strptime('%d-%m-%y %H:%M', stringcolumn(1))) nooutput
tijd = strftime('%H:%M', STATS_max)
set palette defined (-(geb) "#ee0000", 0 "#0000cc", 0 "#00aa00", (zon) "#ff0000")
unset colorbox
set title 'Alle energie-stromen van de laatste 24 uur.' font "Courier-Bold,12"
set xdata time
set timefmt '%d-%m-%y-%H:%M'
set xtics format "%H:%M" # dit is de opmaak zoals je hem gaat zien
set xtics 3600
set mxtics 0 # zet sub(minor)streepjes op de x-as
set grid ls 1 lw 1 lc rgb "#a0a0a0"
set autoscale xfix
set ytics font "Helvetica,8"
set mytics 2
set y2tics axis out 0
set ylabel "V e r m o g e n in Watt" offset 2,1
set object rect from screen 0.05, screen 0.04 to screen 0.08, screen 0.06 fc rgb '#00B900' front
set object rect from sc 0.05, sc 0.01 to sc 0.08, sc 0.03 fc rgb 'blue' front
set object rect from sc 0.25, sc 0.04 to sc 0.28, sc 0.06 fc rgb 'green'
set object 10 rect from sc 0.25, sc 0.01 to sc 0.28, sc 0.03 fc rgb "red" fs solid 1.0 front
set object 10 rect from sc 0.25, sc 0.01 to sc 0.28, sc 0.03 fc rgb "#5555ff" fs solid 1.0 front
# graph x, y
set label font "Courier Bold, 10" # grootte font tbv labels in het grafiek
set label 1 sprintf("Energiestromen gemiddeld per uur.") at screen 0.05,0.08 tc rgb "black" front
set label 2 sprintf("Zon = %4.0f W/h",zonavg) at screen 0.085,0.05 front
set label 3 sprintf("Gebruikt = %4.0f W/h",gebavg) at screen 0.085,0.025 front
set label 4 sprintf("Geleverd = %4.0f W/h",gel) at screen 0.285,0.05 front
set label 5 sprintf("Afgenomen = %4.0f W/h",afn) at screen 0.285,0.025 front
set label 6 sprintf("Energiestromen van de afgelopen 24 uur.") at screen 0.5,0.08 front
set label 7 sprintf("Gebruikt (%dW) = zon (%dW) - geleverd (%dW) + afgenomen (%dW)", gebt, zont, gelt, afnt) at screen 0.5,0.05 tc rgb "black" front
set label 11 sprintf("Logtijd: ") at screen 0.05,0.92 font "Courier-Bold,8" front
set label 12 sprintf(tijd) at screen 0.091,0.92 font "Courier-Bold,8" front
set style fill solid noborder# was transparent solid 0.5 border 0.5
n = 51
# n is het aantal kolommen wat wordt opgebouwd teneinde een gradient te krijgen. Hoe hoger "n" des te vloeiender de gradient
# De 1e serie is zon, de 2e serie is geleverd, de 3e serie is gebruik en de 4e serie is afgenomen.
# Het getal 12 is het aantal punten van één karakter Courier-Bold 10 hetgeen hier is gebruikt voor de labels.
plot for [i=n:0:-1] "<tail -24 ".file."" u ($1-600):(($4/n)*i):(($4/n)*i) w boxes lc palette notitle,\
"<tail -24 ".file."" u ($1-600):4:( $4>0 && ($4/ymax*ptmax)> (12 * strlen(sprintf("%d", $4))) ? $4 : sprintf("")) w labels right rotate font ",10" tc rgb "white" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u ($1-600):4:( $4>0 && ($4/ymax*ptmax)<=(12 * strlen(sprintf("%d", $4))) ? $4 : sprintf("")) w labels left rotate font ",10" tc rgb "black" offset 0,0.1 notitle,\
"<tail -24 ".file."" u ($1-600):4 w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u ($1+600):3 w boxes lt 1 lc rgb "green" fillstyle solid notitle,\
"<tail -24 ".file."" u ($1+600):3 w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u ($1+600):3:( $3>0 && ($3/ymax*ptmax)> (12 * strlen(sprintf("%d", $3))) ? $3 : sprintf("")) w labels right rotate font ",10" tc rgb "blue" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u ($1+600):3:( $3>0 && ($3/ymax*ptmax)<=(12 * strlen(sprintf("%d", $3))) ? $3 : sprintf("")) w labels left rotate font ",10" tc rgb "black" offset 0,0.1 notitle,\
for [i=n:0:-1] "<tail -24 ".file."" u ($1-600):((-($5)/n)*i):((-($5)/n)*i) w boxes lc palette notitle,\
"<tail -24 ".file."" u ($1-600):(-$5):( $5>0 && ($5/ymax*ptmax)> (12 * strlen(sprintf("%d", $5))) ? -$5 : sprintf("")) w labels left rotate font ",10" tc rgb "white" offset 0,0.1 notitle,\
"<tail -24 ".file."" u ($1-600):(-$5):( $5>0 && ($5/ymax*ptmax)<=(12 * strlen(sprintf("%d", $5))) ? -$5 : sprintf("")) w labels right rotate font ",10" tc rgb "black" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u ($1-600):(-$5) w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u ($1+600):(-$2) w boxes lc rgb "#5555ff" fillstyle solid notitle,\
"<tail -24 ".file."" u ($1+600):(-$2) w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u ($1+600):(-$2):( $2>0 && ($2/ymax*ptmax)> (12 * strlen(sprintf("%d", $2))) ? -$2 : sprintf("")) w labels left rotate font ",10" tc rgb "white" offset 0,0.1 notitle,\
"<tail -24 ".file."" u ($1+600):(-$2):( $2>0 && ($2/ymax*ptmax)<=(12 * strlen(sprintf("%d", $2))) ? -$2 : sprintf("")) w labels right rotate font ",10" tc rgb "black" offset 0,-0.1 notitle
The complete datafile can you find here: http://ccvd.eu/downloads/uur.txt
There are two problems: First you must use the correct time format %d-%m-%Y-%H:%M in all cases (in the script you posted, you have a small y, and in the stats command you are missing a dash).
And, second, you must use timecolumn(1) instead of $1 in the using statement in order to have the date parsed correctly. When you had a timestamp, it worked fine since it was only a number, but parsing of the string failed. So your complete script should be
file = 'uur.txt'
set output "dag.png"
set datafile separator ","
set linestyle 1 lt 1 lc rgb "black"
set bmargin 5 # witruimte onder grafiek
set boxwidth 600 absolute
set style boxplot
set border back
dy=500 # zie y waarde terminal
# Hier worden de maximale en minimale y-waarden van gnuplot bepaald.
set terminal unknown
plot "<tail -24 ".file."" using :(-$5) w p, '' u :4 w p
ymax= GPVAL_Y_MAX
ymin= GPVAL_Y_MIN
ptmax=ymax*dy/(ymax-ymin)
ptmin=ymin*dy/(ymax-ymin)
replot
set terminal pngcairo truecolor enhanced size 1200, 500 font "Courier Bold,10" background rgb "#CFCFFF"
stats "<tail -24 ".file."" using 2:3 nooutput
afnt = STATS_sum_x
gelt = STATS_sum_y
afn = afnt/24
gel = gelt/24
stats "< tail -24 ".file."" using 4:5 nooutput
zon = STATS_max_x
zont = STATS_sum_x
geb = STATS_max_y
gebt = STATS_sum_y
zonavg = STATS_sum_x/24
gebavg = STATS_sum_y/24
stats "<tail -1 ".file."" using (strptime('%d-%m-%Y-%H:%M', stringcolumn(1))) nooutput
tijd = strftime('%H:%M', STATS_max)
set palette defined (-(geb) "#ee0000", 0 "#0000cc", 0 "#00aa00", (zon) "#ff0000")
unset colorbox
set title 'Alle energie-stromen van de laatste 24 uur.' font "Courier-Bold,12"
set xdata time
set timefmt '%d-%m-%Y-%H:%M'
set xtics format "%H:%M" # dit is de opmaak zoals je hem gaat zien
set xtics 3600
set mxtics 0 # zet sub(minor)streepjes op de x-as
set grid ls 1 lw 1 lc rgb "#a0a0a0"
set autoscale xfix
set ytics font "Helvetica,8"
set mytics 2
set y2tics axis out 0
set ylabel "V e r m o g e n in Watt" offset 2,1
set object rect from screen 0.05, screen 0.04 to screen 0.08, screen 0.06 fc rgb '#00B900' front
set object rect from sc 0.05, sc 0.01 to sc 0.08, sc 0.03 fc rgb 'blue' front
set object rect from sc 0.25, sc 0.04 to sc 0.28, sc 0.06 fc rgb 'green'
set object 10 rect from sc 0.25, sc 0.01 to sc 0.28, sc 0.03 fc rgb "red" fs solid 1.0 front
set object 10 rect from sc 0.25, sc 0.01 to sc 0.28, sc 0.03 fc rgb "#5555ff" fs solid 1.0 front
# graph x, y
set label font "Courier Bold, 10" # grootte font tbv labels in het grafiek
set label 1 sprintf("Energiestromen gemiddeld per uur.") at screen 0.05,0.08 tc rgb "black" front
set label 2 sprintf("Zon = %4.0f W/h",zonavg) at screen 0.085,0.05 front
set label 3 sprintf("Gebruikt = %4.0f W/h",gebavg) at screen 0.085,0.025 front
set label 4 sprintf("Geleverd = %4.0f W/h",gel) at screen 0.285,0.05 front
set label 5 sprintf("Afgenomen = %4.0f W/h",afn) at screen 0.285,0.025 front
set label 6 sprintf("Energiestromen van de afgelopen 24 uur.") at screen 0.5,0.08 front
set label 7 sprintf("Gebruikt (%dW) = zon (%dW) - geleverd (%dW) + afgenomen (%dW)", gebt, zont, gelt, afnt) at screen 0.5,0.05 tc rgb "black" front
set label 11 sprintf("Logtijd: ") at screen 0.05,0.92 font "Courier-Bold,8" front
set label 12 sprintf(tijd) at screen 0.091,0.92 font "Courier-Bold,8" front
set style fill solid noborder# was transparent solid 0.5 border 0.5
n = 51
# n is het aantal kolommen wat wordt opgebouwd teneinde een gradient te krijgen. Hoe hoger "n" des te vloeiender de gradient
# De 1e serie is zon, de 2e serie is geleverd, de 3e serie is gebruik en de 4e serie is afgenomen.
# Het getal 12 is het aantal punten van één karakter Courier-Bold 10 hetgeen hier is gebruikt voor de labels.
plot for [i=n:0:-1] "<tail -24 ".file."" u (timecolumn(1)-600):(($4/n)*i):(($4/n)*i) w boxes lc palette notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):4:( $4>0 && ($4/ymax*ptmax)> (12 * strlen(sprintf("%d", $4))) ? $4 : sprintf("")) w labels right rotate font ",10" tc rgb "white" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):4:( $4>0 && ($4/ymax*ptmax)<=(12 * strlen(sprintf("%d", $4))) ? $4 : sprintf("")) w labels left rotate font ",10" tc rgb "black" offset 0,0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):4 w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):3 w boxes lt 1 lc rgb "green" fillstyle solid notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):3 w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):3:( $3>0 && ($3/ymax*ptmax)> (12 * strlen(sprintf("%d", $3))) ? $3 : sprintf("")) w labels right rotate font ",10" tc rgb "blue" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):3:( $3>0 && ($3/ymax*ptmax)<=(12 * strlen(sprintf("%d", $3))) ? $3 : sprintf("")) w labels left rotate font ",10" tc rgb "black" offset 0,0.1 notitle,\
for [i=n:0:-1] "<tail -24 ".file."" u (timecolumn(1)-600):((-($5)/n)*i):((-($5)/n)*i) w boxes lc palette notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):(-$5):( $5>0 && ($5/ymax*ptmax)> (12 * strlen(sprintf("%d", $5))) ? -$5 : sprintf("")) w labels left rotate font ",10" tc rgb "white" offset 0,0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):(-$5):( $5>0 && ($5/ymax*ptmax)<=(12 * strlen(sprintf("%d", $5))) ? -$5 : sprintf("")) w labels right rotate font ",10" tc rgb "black" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):(-$5) w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):(-$2) w boxes lc rgb "#5555ff" fillstyle solid notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):(-$2) w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):(-$2):( $2>0 && ($2/ymax*ptmax)> (12 * strlen(sprintf("%d", $2))) ? -$2 : sprintf("")) w labels left rotate font ",10" tc rgb "white" offset 0,0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):(-$2):( $2>0 && ($2/ymax*ptmax)<=(12 * strlen(sprintf("%d", $2))) ? -$2 : sprintf("")) w labels right rotate font ",10" tc rgb "black" offset 0,-0.1 notitle
with the expected output of
I need to draw a batch of scatter charts in matplotlib, and found the speed of matplotlib is slow, then I lineprofile the function, and found the hotspot is fig, ax = plt.subplots(), It costs 56.1% of time to creat a blank figure and axes !!
How to speed it up ? I mean, how can I reuse fig and ax to avoid creating them each time ?
Attach the profile report here (I cut some of the line to make it simple)
Total time: 0.733771 s
Line # Hits Time Per Hit % Time Line Contents
==============================================================
517 #profile
518 def df_scatter(df):
519 ''' draw the scatter plot for Pandas dataframe 'df'
533 '''
536
537 1 75 75.0 0.0 biggest_area = 1000
538 1 117 117.0 0.0 mycm = matplotlib.cm.get_cmap('jet') # 'spectral'
539
541 1 78 78.0 0.0 col_qty = len(df.columns)
543
544 1 1859 1859.0 0.1 x = list(df.ix[:,0].values)
545 1 1258 1258.0 0.0 y = list(df.ix[:,1].values)
551
552 1 1472345 1472345.0 56.1 fig, ax = plt.subplots()
556
557 1 7007 7007.0 0.3 plt.subplots_adjust(left=0.07, right=0.92, bottom=0.1, top=0.95)
558 1 179 179.0 0.0 x_margin, y_margin = (max(x)-min(x))/20, (max(y)-min(y))/20
563
564 1 71 71.0 0.0 if col_qty > 2:
565 1 1602 1602.0 0.1 r = list(df.ix[:,2].values)
566 1 309 309.0 0.0 size_r = np.array(biggest_area)*r/max(r)
585
586 1 34712 34712.0 1.3 sc = plt.scatter(x, y, marker='o', s=size_r, cmap=mycm, alpha=0.65)
587
588 # adding colorbar
589 1 542417 542417.0 20.7 cbaxes = fig.add_axes([0.94, 0.25, 0.02, 0.70])
590 1 165719 165719.0 6.3 cbar = plt.colorbar(sc, cax=cbaxes)
591 1 122 122.0 0.0 cbar.solids.set_edgecolor('face')
595
602 1 1061 1061.0 0.0 plt.figtext(0.94,0.10,"%0.1f"%(max(r)), fontproperties=TEXT_FONT_MEDIUM)
639 1 66 66.0 0.0 return fig
I think that the best way to do it is calling
fig = plt.figure()
ax=fig.add_subplot(111)
from outside of df_scatter. Then, pass it to df_scatter as arguments:
df_scatter(df,fig,ax):
or simply do inside df_scatter:
def df_scatter(df):
fig = plt.gcf()
ax = plt.gca()
after the creation of fig & axis was done.
I have a small .eps file which uses bezier curves with a thick linewidth to achieve a certain effect. This file displays as I expect it to in gv, but when I convert it to a .pdf (eg with ps2pdf or by opening the file with Preview on a Mac running OSX) it renders some of the curves incorrectly (or at least, not in the way I was expecting); in the middle of the curve, the normals to the curve seem to "flip over", producing a strange artifact.
Here is the .eps file in question, as code:
%!PS-Adobe-2.0 EPSF-2.0
%%BoundingBox: 0 0 750 200
gsave 50 50 scale 1 3 translate
/edge{4 dict begin
/y2 exch def
/x2 exch def
/y1 exch def
/x1 exch def
gsave
1 setgray
1 8 div setlinewidth
newpath
x1 y1 moveto x2 y2 lineto
stroke
0 setgray
1 20 div setlinewidth
newpath
x1 y1 moveto x2 y2 lineto
stroke
x1 y1 0.07 0 360 arc fill stroke
x2 y2 0.07 0 360 arc fill stroke
grestore
end}def
/cur_edge{7 dict begin
/T exch def
/angle2 exch def
/y2 exch def
/x2 exch def
/angle1 exch def
/y1 exch def
/x1 exch def
gsave
1 setgray
1 8 div setlinewidth
newpath
x1 y1 moveto
x1 angle1 cos T mul add y1 angle1 sin T mul add
x2 angle2 cos T mul add y2 angle2 sin T mul add
x2 y2 curveto
stroke
0 setgray
1 20 div setlinewidth
newpath
x1 y1 moveto
x1 angle1 cos T mul add y1 angle1 sin T mul add
x2 angle2 cos T mul add y2 angle2 sin T mul add
x2 y2 curveto
stroke
x1 y1 0.07 0 360 arc fill stroke
x2 y2 0.07 0 360 arc fill stroke
grestore
end}def
/fat_edge{7 dict begin
/T exch def
/angle2 exch def
/y2 exch def
/x2 exch def
/angle1 exch def
/y1 exch def
/x1 exch def
gsave
0 setgray
1 4 div setlinewidth
newpath
x1 y1 moveto
x1 angle1 cos T mul add y1 angle1 sin T mul add
x2 angle2 cos T mul add y2 angle2 sin T mul add
x2 y2 curveto
stroke
0.9 setgray
1 5 div setlinewidth
newpath
x1 y1 moveto
x1 angle1 cos T mul add y1 angle1 sin T mul add
x2 angle2 cos T mul add y2 angle2 sin T mul add
x2 y2 curveto
stroke
grestore
end}def
/fat_vertex{4 dict begin
/angle exch def
/y exch def
/x exch def
/T 0.14 def
gsave
0.9 setgray
1 5.5 div setlinewidth
newpath
x y moveto
x angle cos T mul add y angle sin T mul add lineto
stroke
grestore
end}def
/extra_fat_vertex{5 dict begin
/y exch def
/x exch def
/w 0.16 def
gsave
1 setgray
newpath
x w sub y w sub moveto
x w add y w sub lineto
x w add y w add lineto
x w sub y w add lineto
closepath
fill
stroke
0 setgray
/v 0.12 def
newpath
x v sub y v sub moveto
x v add y v sub lineto
x v add y v add lineto
x v sub y v add lineto
closepath
fill
0.9 setgray
/u 0.095 def
newpath
x u sub y u sub moveto
x u add y u sub lineto
x u add y u add lineto
x u sub y u add lineto
closepath
fill
grestore
end}def
/extra_fat_triangle{5 dict begin
/y exch def
/x exch def
/w 0.16 def
gsave
1 setgray
newpath
x w sub y w sub moveto
x w 1.1 mul add y lineto
x w sub y w add lineto
closepath
fill
stroke
0 setgray
/v 0.12 def
newpath
x v sub y v sub moveto
x v add y lineto
x v sub y v add lineto
closepath
fill
0.9 setgray
/u 0.095 def
newpath
x u sub y u sub moveto
x u 0.85 mul add y lineto
x u sub y u add lineto
closepath
fill
grestore
end}def
/extra_fat_triangle_left{5 dict begin
/y exch def
/x exch def
/w 0.16 def
gsave
1 setgray
newpath
x w add y w sub moveto
x w 1.1 mul sub y lineto
x w add y w add lineto
closepath
fill
stroke
0 setgray
/v 0.12 def
newpath
x v add y v sub moveto
x v sub y lineto
x v add y v add lineto
closepath
fill
0.9 setgray
/u 0.095 def
newpath
x u add y u sub moveto
x u 0.85 mul sub y lineto
x u add y u add lineto
closepath
fill
grestore
end}def
0 0 90 2 0 270 1 cur_edge
% 0 0 270 2 0 90 1 cur_edge
2 0 90 0 0 270 1 cur_edge
0 0 180 0.5 -2 180 1 cur_edge
0.5 -2 90 1.5 -1.3 180 0.5 cur_edge
1.5 -1.3 270 2.5 -2 270 0.7 cur_edge
2.5 -2 90 0.5 -2 270 1 cur_edge %
2.5 -2 0 3 -0.75 0 1 cur_edge
3 -0.75 270 1.5 -1.3 0 0.7 cur_edge
3 -0.75 180 1.5 -1.3 90 0.7 cur_edge
3 -0.75 90 2 0 0 0.5 cur_edge
5 0 translate
0 0 90 2 0 270 1 fat_edge
% 0 0 270 2 0 90 1 fat_edge
2 0 90 0 0 270 1 fat_edge
0 0 180 0.5 -2 180 1 fat_edge
0.5 -2 90 1.5 -1.3 180 0.5 fat_edge
1.5 -1.3 270 2.5 -2 270 0.7 fat_edge
2.5 -2 90 0.5 -2 270 1 fat_edge
2.5 -2 0 3 -0.75 0 1 fat_edge
3 -0.75 270 1.5 -1.3 0 0.7 fat_edge
3 -0.75 180 1.5 -1.3 90 0.7 fat_edge
3 -0.75 90 2 0 0 0.5 fat_edge
0 0 90 fat_vertex
0 0 180 fat_vertex
0 0 270 fat_vertex
2 0 0 fat_vertex
2 0 90 fat_vertex
2 0 270 fat_vertex
0.5 -2 180 fat_vertex
0.5 -2 90 fat_vertex
2.5 -2 90 fat_vertex
2.5 -2 270 fat_vertex
1.5 -1.3 0 fat_vertex
1.5 -1.3 90 fat_vertex
1.5 -1.3 180 fat_vertex
1.5 -1.3 270 fat_vertex
3 -0.75 0 fat_vertex
3 -0.75 90 fat_vertex
3 -0.75 180 fat_vertex
3 -0.75 270 fat_vertex
5 0 translate
0 0 90 2 0 270 1 fat_edge
% 0 0 270 2 0 90 1 fat_edge
2 0 90 0 0 270 1 fat_edge
0 0 180 0.5 -2 180 1 fat_edge
0.5 -2 90 1.5 -1.3 180 0.5 fat_edge
1.5 -1.3 270 2.5 -2 270 0.7 fat_edge
2.5 -2 90 0.5 -2 270 1 fat_edge
2.5 -2 0 3 -0.75 0 1 fat_edge
3 -0.75 270 1.5 -1.3 0 0.7 fat_edge
3 -0.75 180 1.5 -1.3 90 0.7 fat_edge
3 -0.75 90 2 0 0 0.5 fat_edge
0 0 90 fat_vertex
0 0 180 fat_vertex
0 0 270 fat_vertex
2 0 0 fat_vertex
2 0 90 fat_vertex
2 0 270 fat_vertex
0.5 -2 180 fat_vertex
0.5 -2 90 fat_vertex
2.5 -2 90 fat_vertex
2.5 -2 270 fat_vertex
1.5 -1.3 0 fat_vertex
1.5 -1.3 90 fat_vertex
1.5 -1.3 180 fat_vertex
1.5 -1.3 270 fat_vertex
3 -0.75 0 fat_vertex
3 -0.75 90 fat_vertex
3 -0.75 180 fat_vertex
3 -0.75 270 fat_vertex
0 0 extra_fat_triangle
2 0 extra_fat_triangle_left
0.5 -2 extra_fat_triangle
1.5 -1.3 extra_fat_vertex
2.5 -2 extra_fat_triangle_left
3 -0.75 extra_fat_vertex
grestore
%eof
What is curious is that the .pdf only displays incorrectly when it is resized to certain specific sizes (or: it displays correctly at certain sizes). I don't seem to be able to predict when it will work.
Here is how it displays (part of the image) correctly:
And here it is resized and displaying incorrectly:
(source: dannyc at math.uchicago.edu)
Note that these images are .jpgs obtained from the .pdf. If you save the code above as an .eps file and open it with Preview on a Mac, I assume it will exhibit the same pathology it did on my computer.
Any advice would be very welcome. I don't know enough (or: anything) about how bezier curves are displayed in .pdf to know what might be the problem here.
Here's a cut down case that displays the same rendering problem:
%!PS-Adobe-2.0 EPSF-2.0
%%BoundingBox: 0 0 400 200
gsave 50 50 scale 1 3 translate
0 setgray
0.05 setlinewidth
newpath
0 0 moveto
0 1 2 -1 2 0 curveto
stroke
grestore
%eof
Can't get much simpler than that: a Bezier path with just two points, all with integer values.
It looks like Apple's renderer has some numeric instability around the center of the curve. If you tweak one of the curve control points by a tiny amount, the bug doesn't happen:
0 1.00001 2 -1 2 0 curveto
So there's a workaround: In your original file, add a small fudge factor (a fraction of a degree) to one of the angles in each curve.
I changed each /angle1 exch def to 0.01 add /angle1 exch def, and it worked for me. Here's the EPS file and the resulting PDF file.
(Of course this shouldn't be necessary, but until you file a bug and Apple releases a fix, it may be the most expedient solution.)