Using yrange in pie charts?

This only works for me if I don't install yrange.

Let's say I have sample-time-overview.csv like

 ,avg,std,,,TProc,2267.5202096317,4573.0532262204 TParse,4.9922379603,138.6595434301,,,,, THash,86.4020623229,548.8593468508,,,,, TEnq,1.1181869688,2.0684998031,,,,, TInQ,1482.2243626062,4257.8024051927,,,,, TSend,2253.1871161473,4514.2823125251,,,,, TWait,1.7578696884,43.1050730747,,,,, TAnsw,14.3452407932,201.9216484892,,,,, TProcAll,2269.2780793201,4573.3927526674,,,,, TTotal,3853.3679320114,7095.0740689587,,,,, 

where I am not interested in the first or last two lines.

Basically copy the code from the above link with minor tweaks:

 #!/usr/bin/gnuplot reset filename = "sample-time-overview" set terminal pngcairo size 500,500 enhanced font 'Verdana,10' set output filename."_piechart.png" #set title "" unset border unset tics set xrange[-1:1.5] #uncommend yrange and the plotdisappears #set yrange[-1.25:1.25] centerX=0 centerY=0 radius=1 set datafile separator ',' set key off set style fill solid 1 stats filename.".csv" u 2 every ::1::7 noout prefix "A" angle(x)=x*360/A_sum percentage(x)=x*100/A_sum pos=0.0 colour=0 yi=0 plot filename.".csv" u (centerX):(centerY):(radius):(pos):(pos=pos+angle($2)):(colour=colour+1) every::1::7 w circle lc var system(sprintf("display %s_piechart.png", filename)) 

it looks like

enter image description here

I will uncomment yrange and comment on unset border , and it looks like this:

enter image description here

which is very annoying because when I try to add tags ...

 plot filename.".csv" u (centerX):(centerY):(radius):(pos):(pos=pos+angle($2)):(colour=colour+1) every::1::7 w circle lc var,\ "" u (1.5):(yi=yi+0.5/A_records):($1) every::1::7 w labels 

it will happen:

enter image description here

I suspect this is due to the lack of yrange (because apart from this, the code is not much different from what was posted in the linked answer).

How can I get the hell out of work?

+1
formatting offset pie-chart gnuplot
source share
2 answers

It is better to configure the chart parameters immediately before the plot command. Other routines (e.g. stats and therefore A_sum ) will be affected by these properties (e.g. set yrange ). This is why the pie chart disappears.

Also, make sure the unit lengths are equal for the x and y axes (use set size ratio -1 ). If not, the circle will be drawn relative to the size of the canvas, and not relative to the axes. The pie chart will look different (unless the corresponding yrange ).

With some changes, I get this diagram: pie chart

This is the code:

 filename = 'sample-time-overview' rowi = 1 rowf = 7 # obtain sum(column(2)) from rows 1 to 7 set datafile separator ',' stats filename.'.csv' u 2 every ::rowi::rowf noout prefix "A" angle(x)=x*360/A_sum percentage(x)=x*100/A_sum # circumference dimensions for pie-chart centerX=0 centerY=0 radius=1 # label positions yposmin = 0.0 yposmax = 0.95*radius xpos = 1.5*radius ypos(i) = yposmax - i*(yposmax-yposmin)/(1.0*rowf-rowi) #------------------------------------------------------------------- # now we can configure the canvas set style fill solid 1 # filled pie-chart unset key # no automatic labels unset tics # remove tics unset border # remove borders; if some label is missing, comment to see what is happening set size ratio -1 # equal scale length set xrange [-radius:2*radius] # [-1:2] leaves place for labels set yrange [-radius:radius] # [-1:1] #------------------------------------------------------------------- pos = 0 # init angle colour = 0 # init colour # 1st line: plot pie-chart # 2nd line: draw colored boxes at (xpos):(ypos) # 3rd line: place labels at (xpos+offset):(ypos) plot filename.'.csv' u (centerX):(centerY):(radius):(pos):(pos=pos+angle($2)):(colour=colour+1) every ::rowi::rowf w circle lc var,\ for [i=0:rowf-rowi] '+' u (xpos):(ypos(i)) wp pt 5 ps 4 lc i+1,\ for [i=0:rowf-rowi] filename.'.csv' u (xpos):(ypos(i)):(sprintf('%05.2f%% %s', percentage($2), stringcolumn(1))) every ::i+1::i+1 w labels left offset 3,0 
+3
source share

Configuring yrange also affects the execution of the stats command. Therefore, you should try set yrange[-1.25:1.25] after the stats command, but not before.

PS:

Labeling on

 plot filename.'.csv' u (1.5):(yi=yi+0.5/A_records):($1) every::1::7 w labels 

not working for me. I have to remove the dollar sign:

 plot filename.'.csv' u (1.5):(yi=yi+0.5/A_records):1 every::1::7 w labels 

And I need to slightly change the values โ€‹โ€‹of 1.5 and 0.5.

0
source share

All Articles