Saturday, December 29, 2012

Pie charting with gnuplot

In two of my previous posts (post-1 post-2), I have talked about how to plot a pie chart using gnuplot. This time I will introduce a new method witch is much more simpler.

This new method will use the plotstyle "circle". And this feather is not provide since gnuplot version 4.6. So you have to update your gnuplot to a version not lower than 4.6.

set term post eps color enhanced size 5cm,5cm
set output "pie_chart.eps"

set size square
set xrange [-1:1]
set yrange [-1:1]
set style fill solid 1

unset border
unset tics
unset key

plot '-' with circle linecolor var
0 0 1 0   30  1
0 0 1 30  60  2
0 0 1 60  120 3
0 0 1 120 190 4
0 0 1 190 275 5
0 0 1 275 360 6
e
##the first two numbers 0 0 are the
# x and y coordinate of center
##the third number 1 is the radius
#of the circle
##the fourth and fifth number are the
#begin and end angle of the sector
##the last number is the color indicate

set output

Fig.1 Pie charting using gnuplot

13 comments:

  1. How would you label each slice?

    ReplyDelete
    Replies
    1. You can have a loot at http://gnuplot-surprising.blogspot.com/2011/10/pie-chart-in-gnuplot.html where each slice is labeled.

      Delete
    2. I did, and ended up just using your python script on that page to do what I needed. I'd really like to use the format on this page as it gives me a little more flexibility when I generate my dataset from the database, but I'm having a hard time getting labels to show up correctly.

      Thanks anyway.

      Delete
    3. label example
      add 7th column to the data with the labels
      plot instruction could then be:

      set angles degrees
      plot 'datafile' u 1:2:3:4:5:6 with circles lc var, '' u (cos($3+(($4-$3)/2))):(sin($3+(($4-$3)/2))):7 with labels

      Delete
  2. Great content, used this site for reference for gnuplot quite a bit. Any books or sites you recommend to get really familiar with gnuplot?

    ReplyDelete
  3. Outstanding blog thanks for sharing such wonderful blog with us ,after long time came across such knowlegeble blog. keep sharing such informative blog with us.
    Machine learning training in chennai
    machine learning course fees in chennai
    best training insitute for machine learning

    ReplyDelete
  4. We develop free teaching aids for parents and educators to teach English to pre-school children. For more info please visit here: English for children

    ReplyDelete
  5. A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post.

    Web Design Company Cheltenham
    SEO Agency Cheltenham

    ReplyDelete
  6. HVAC & Plumbing Services
    Air Star Heating guarantees reliability and quality for all equipment and services.

    Air Star Heating specialists always try to deliver the most excellent quality of services to our customers at an affordable price. It is understood that every client has different needs and different problems. We try to accomplish the needs of every client according to their requests. We are having considerable experience in this field. Our specialists understand very well how things work. It doesn’t matter in which field of industry you are looking for services.
    Plumbing & HVAC Services in San Diego. Call now (858) 900-9977 ✓Licensed & Insured ✓Certified Experts ✓Same Day Appointment ✓Original Parts Only ✓Warranty On Every Job.
    Visit:- https://airstarheating.com

    ReplyDelete

Creative Commons License
Except as otherwise noted, the content of this page is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.