LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   creating graphics from file (https://www.linuxquestions.org/questions/linux-software-2/creating-graphics-from-file-711599/)

DeepSeaNautilus 03-14-2009 11:56 AM

creating graphics from file
 
Hello, is there an application that can read a file with x-y values and then create a graphic as a jpg 2d image (or other image format) as output?
The file would be like this:
Code:

Person - Posts
Michael - 5
John - 10
Robin - 15

Thanks in advance.

David the H. 03-14-2009 12:18 PM

I think you need to define your desired output a bit more clearly. I really don't understand what you want at this point. By "graphic" do you mean a graph? What kind of graph? How should the data be displayed?

jlinkels 03-14-2009 12:31 PM

Gnuplot

jlinkels

pixellany 03-14-2009 12:43 PM

A spreadsheet program typically has plotting capabilities----something like OpenOffice calc will open most ordered files.

DeepSeaNautilus 03-14-2009 02:12 PM

Quote:

Originally Posted by David the H. (Post 3475439)
I think you need to define your desired output a bit more clearly. I really don't understand what you want at this point. By "graphic" do you mean a graph? What kind of graph? How should the data be displayed?

The output I want is a bar chart jpg image. I am looking for a console application so I can create the bar charts using a bash script. The data should be displayed, in the x axis, the names of the persons and in the y axis, the number of posts they have made. This is only an example, the real files have much more data and it will be a really tedious thing to do it manually using open office. I want to make bar charts similar to those you would get by creating the bar charts in open office´s calc, then taking a screen shoots from them and saving them with jpg format. The thing is that I don't want to do this process manually, but automatically using a bash script.

DeepSeaNautilus 03-14-2009 02:16 PM

Quote:

Originally Posted by pixellany (Post 3475463)
A spreadsheet program typically has plotting capabilities----something like OpenOffice calc will open most ordered files.

I know, but is there any way I can use OpenOffice calc or any other program in a bash script to create several bar charts automatically by giving them the files with the information required?

jschiwal 03-14-2009 02:39 PM

You can use gnuplot to produce a bar graph & use the jpeg output driver. You may want to produce a file containing the data in a form gnu plot expects, write a gnuplot script that will use this datafile and create the jpeg graph, and then call: gnuplot <your_gnu_plot_script>.
From the info file:
Code:

  Examples:

  To plot a data file with solid filled boxes with a small vertical
space separating them (bargraph):

          set boxwidth 0.9 relative
          set style fill solid 1.0
          plot 'file.dat' with boxes

Also use locate to locate the html and/or pdf documentation for gnuplot.

Other options could be using postscript or latex graphic commands. There is a gnuplottex version of latex, but I don't know if you can produce jpeg files from the results.

There is also the plotutils package including the plot command. They can produce ps, png or psuedo-gif files as output which you could convert easily to jpeg.

From the plot info manual:
Code:

To produce a PNG file, you would do
    plot -T png < test.meta > test.png

If you will be using these plots for a college paper, you may want to use an eps output filter instead of png. LaTeX works better importing eps graphics. ( pdftex may be different )

DeepSeaNautilus 03-14-2009 02:42 PM

Quote:

Originally Posted by jlinkels (Post 3475452)
Gnuplot

jlinkels

Hello, thanks for the tip. I have searched gnuplot in google and it seems it could be just what I need, but the example source codes (http://gnuplot.sourceforge.net/demo/histograms.html) only make reference to an inmigration.dat file in which the data is stored. Do you know what is the format required to input this data? Thanks

DeepSeaNautilus 03-14-2009 02:53 PM

Quote:

Originally Posted by jschiwal (Post 3475548)
You can use gnuplot to produce a bar graph & use the jpeg output driver. You may want to produce a file containing the data in a form gnu plot expects, write a gnuplot script that will use this datafile and create the jpeg graph, and then call: gnuplot <your_gnu_plot_script>.
From the info file:
Code:

  Examples:

  To plot a data file with solid filled boxes with a small vertical
space separating them (bargraph):

          set boxwidth 0.9 relative
          set style fill solid 1.0
          plot 'file.dat' with boxes

Also use locate to locate the html and/or pdf documentation for gnuplot.

Other options could be using postscript or latex graphic commands. There is a gnuplottex version of latex, but I don't know if you can produce jpeg files from the results.

There is also the plotutils package including the plot command. They can produce ps, png or psuedo-gif files as output which you could convert easily to jpeg.

From the plot info manual:
Code:

To produce a PNG file, you would do
    plot -T png < test.meta > test.png

If you will be using these plots for a college paper, you may want to use an eps output filter instead of png. LaTeX works better importing eps graphics. ( pdftex may be different )

Thanks a lot for the help , it seems that gnuplot is the right program for what I need. I have to install a separate jpeg output driver or is it integrated with gnuplot? I will start to read gnuplot docs and I will come back to post if I have any more doubts.

jschiwal 03-14-2009 03:38 PM

Code:

NAME
      convert - convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.

SYNOPSIS
      convert input-file [options] output-file

OVERVIEW
      The  convert  program is a member of the ImageMagick(1) suite of tools.  Use it to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip,
      join, re-sample, and much more.

      For more information about the convert command, point your browser to file:///usr/share/doc/ImageMagick-6.4.3/www/convert.html or http://www.imagemagick.org/script/convert.php.

to convert a file from png to jpg, simply use
convert <pngfilename> <jpegfilename>
or
more generally:
convert $pngfile ${pngfile%.png}.jpg

the plot and gnuplot programs may have documentation in your /usr/share/doc/ directory. I have html & pdf documentation. The pdf file is about 200 pages long.

DeepSeaNautilus 03-14-2009 04:46 PM

Quote:

Originally Posted by jschiwal (Post 3475579)
Code:

NAME
      convert - convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.

SYNOPSIS
      convert input-file [options] output-file

OVERVIEW
      The  convert  program is a member of the ImageMagick(1) suite of tools.  Use it to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip,
      join, re-sample, and much more.

      For more information about the convert command, point your browser to file:///usr/share/doc/ImageMagick-6.4.3/www/convert.html or http://www.imagemagick.org/script/convert.php.

to convert a file from png to jpg, simply use
convert <pngfilename> <jpegfilename>
or
more generally:
convert $pngfile ${pngfile%.png}.jpg

the plot and gnuplot programs may have documentation in your /usr/share/doc/ directory. I have html & pdf documentation. The pdf file is about 200 pages long.

Thanks I already installed gnuplot and made my first graphs using a IBM Tutorial ( http://www.ibm.com/developerworks/li...r-wikiaGnuplot ), it seems really nice. I am currently compiling imagemagick and I think it is going to be very useful to me also. Thanks for being generous with your knowledge.

jschiwal 03-15-2009 12:48 PM

Use your package manager to install ImageMagick. Only extremely small pendrive based distro's won't have it. The package will also install the documentation. The manpages for each ImageMagick program contain a link to documentation on their site:
file:///usr/share/doc/ImageMagick-6.4.3/www/convert.html or http://www.imagemagick.org/script/convert.php.

Your documentation may be in /usr/share/doc/packages/ImageMagick/ if you have SuSE Linux.

DeepSeaNautilus 03-16-2009 10:08 PM

Quote:

Originally Posted by jschiwal (Post 3476244)
Use your package manager to install ImageMagick. Only extremely small pendrive based distro's won't have it. The package will also install the documentation. The manpages for each ImageMagick program contain a link to documentation on their site:
file:///usr/share/doc/ImageMagick-6.4.3/www/convert.html or http://www.imagemagick.org/script/convert.php.

Your documentation may be in /usr/share/doc/packages/ImageMagick/ if you have SuSE Linux.

I got an error when I tried to install it by compiling it, so I installed it using my packet manager as you say and it works pretty well, thanks. I have seen a couple of examples of how to do bar charts in gnuplot, but I have not find the format required for the data.dat file than is referenced in the gnuplot file. Could you help me with this?

DeepSeaNautilus 03-17-2009 06:08 PM

how can I rotate the x label tags
 
Hello, I make this script for creating a bar chart:
set encoding iso_8859_1

Code:

set terminal postscript color
set output "example2.eps"


set xrange [0:30]
set yrange [0:5]
set xtics ("uno" 1, "dos" 2, "tres" 3, "cuatro" 4)

set data style boxes
set boxwidth 0.2

#comentario
plot "example.dat" using 1:2 title "first record"

The problem is that when I have a lot of data, the labels of the x axis overlap, is there any way I can rotate the tags 90 degrees?

jlinkels 03-17-2009 06:53 PM

Yes you can.

Follow this link: http://www.gnuplot.info/docs/node193.html

All those pages together comprise a wonderful object which is commonly referred to as a manual.

jlinkels


All times are GMT -5. The time now is 03:12 AM.