0

I have a txt file with names and quantities, for example:

1 70 cats
2 64 dogs
3 54 birds
4 30 turtles

how can I, only with gnuplot, generate a chart in which the names below and their respective quantities appear on the right ?

  • What have you tried so far? Have you checked the manual and the gnuplot homepage and basic tutorials? Are you talking of a vertical bar graph or a horizontal bar graph? Please clarify and/or add a sketch to illustrate. – theozh Apr 11 '21 at 12:56
  • Yes, I read it but I couldn’t find it, it’s a box Graph bar, with the names written horizontally – Lucas Gomes Apr 11 '21 at 13:01
  • is someone like that : https://stackoverflow.com/questions/327576/how-do-you-plot-bar-charts-in-gnuplot but I tried the way this one there and it didn’t work – Lucas Gomes Apr 11 '21 at 13:01
  • What does "didn't work" mean? Which of the many different answers did you try? Please show some code, result (error message or output graph) and a description of what is different to your desired result. – theozh Apr 11 '21 at 13:45

1 Answers1

0

If the graph you want to create is just a point chart, you can do it by combining the with points and with labels plots. Here is a sample code.

$TestData <<EOD
1 70 cats
2 64 dogs
3 54 birds
4 30 turtles
5 25 "other animals"
EOD

set xrange [0:6]
set yrange [0:100]
set key noautotitle

plot $TestData using 1:2 with points ps 2 pt 7, \
     ""        using 1:2:(strcol(3)) with labels offset 0,-1 center, \
     ""        using 1:2:(strcol(2)) with labels offset 2,0 left

Image generated by sample code

binzo
  • 1,527
  • 1
  • 3
  • 13