| New Reply |
quality graph with gnuplot and latex |
Share Thread | Thread Tools |
| Dec3-11, 03:40 AM | #1 |
|
|
quality graph with gnuplot and latex
I want to include graphics in a latex document, so I used various terminal (png, jpg) in gnuplot but when I include in latex, the result it isn't very good...i would coloured graph , so which terminal i can use? what pagkage i have to include in tex file?
Thanks for helpers |
| Dec3-11, 06:41 AM | #2 |
|
Recognitions:
|
Pure LaTeX prefers postscript or encapsulated postscript (ps or eps) files.
These can get very big, especially for color. PdfLaTeX will handle many different compressed file formats, which will look bad if you scale them in your document - especially graphs, like those produced by gnu plot, which usually have thin lines. The answer is to create the images at the size you want to use it - maybe rescaling it with an image manipulaton program (I use GIMP for eg.) For graphs or diagrams which have lots of lines and thin bits that are important, you want a format that uses lossless compression like png. |
| Dec3-11, 09:50 AM | #3 |
|
|
What is the nature of the graphics?
If the graphics are fine lines and dots, then use vector-formats (like .eps) since they look better when rescaled. Otherwise, use raster-formats (like .png). Have you seen http://t16web.lanl.gov/Kawano/gnuplot/postscript-e.html In latex, use the graphics or graphicx packages. http://t16web.lanl.gov/Kawano/gnuplot/postproc-e.html |
| Dec3-11, 10:14 AM | #4 |
|
|
quality graph with gnuplot and latexCode:
set terminal epslatex size 4,2.82 standalone color colortext 9 set output 'image.tex' plot f(x) # example Code:
latex image.tex dvips image.dvi ps2pdf image.ps Code:
\includegraphics[scale=1.00]{image.pdf}
The result is fine, but there is a better solution? |
| Dec3-11, 11:03 AM | #5 |
|
|
Maybe something like this....
set terminal postscript size 4,2.82 standalone color colortext 9 set output 'image.eps' plot f(x) # example and then in the latex file: \includegraphics[scale=1.00]{image.eps} |
| Dec3-11, 11:45 AM | #6 |
|
|
|
| Dec3-11, 12:25 PM | #7 |
|
Recognitions:
|
I've been using:
\usepackage[pdftex]{color,graphicx} In the body: Code:
\begin{figure}
\centering
\includegraphics[angle=0, width=0.67\textwidth]{my-pic.png}
\end{figure}
Oh yeah - it is supposed to do pdf - I'll go try to repeat your problem. [edit] Hmmm ... works for me using: ps2pdf testimage.eps ... and using the same \includegraphics[scale=1]{testimage.pdf} ... you did. Suggest: 1. check the image is not blank at each stage in the processing 2. use pdflatex directly in the terminal 3. try just using the ps Sounds to me like your shortcut is only invoking latex, not pdflatex. |
| Dec3-11, 12:49 PM | #8 |
|
|
this is the preamble:
Code:
\documentclass[a4paper,italian,12pt]{article}
\usepackage{babel}
\usepackage[hmargin=2.5cm,vmargin=2.5cm,dvips]{geometry}
%%\usepackage{draftcopy}
\usepackage[latin1]{inputenc}
\usepackage{ae}
\usepackage{aecompl}
\usepackage{aeguill}
\usepackage{textcomp}
\usepackage{mathcomp}
%% \usepackage[draft]{graphicx}
\usepackage[final]{graphicx}
\usepackage{latexsym}
\usepackage{amstext}
%% \usepackage[mathlines,pagewise]{lineno}
\usepackage{xspace}
\usepackage[section,below]{placeins}
\usepackage{array}
\usepackage{tabularx}
\usepackage{subfigure}
\usepackage[small]{caption}
\usepackage{url}
\usepackage{booktabs}
\usepackage{afterpage}
\usepackage{parskip}
...
\begin{center}
\includegraphics[scale=1.60]{img/image.eps}
\label{fig:image}
\end{center}
Code:
! LaTeX Error: Unknown graphics extension: .eps. |
| Dec3-11, 02:19 PM | #9 |
|
Recognitions:
|
pdflatex does not recognize eps.
It should recognize .pdf though. Use regular LaTeX for eps files. (when testing, change only one thing at a time.) I'm getting a blank page instead of an image - this what you get? The error is: LaTeX Warning: Float too large for page [...] When I convert to pdf, the image is A4 size with the image in the bottom-left corner - which is off the bottom of the page! epstopdf image.eps creates a properly dimentioned file. I tried this with your code, (Oh cool - Italian!) and all your includes (jic there were conflicting packages) and it worked for me. Curiously, when I use just plain latex I get an error: ! LaTeX Error: Cannot determine size of graphic in image.pdf (no BoundingBox). But it works anyway ... so I guess I was wrong about latex graphicx not accepting pdf format. |
| Dec3-11, 03:04 PM | #10 |
|
|
yes, converting eps or ps to a pdf it works... but in this way the quality of lines became a bit low :(
|
| Dec3-11, 05:19 PM | #11 |
|
Recognitions:
|
Though you are scaling up - so you must get pixelation.
You don't seem to be invoking any of the special features of pdf files, you you could load the eps file in the .tex then use normal latex to get a .dvi file, then dvipdf. Even so - recall that pdf uses (lossy) jpeg compression. If you just need to print it - use dvips instead and print the (likely huge) ps document. If you need to submit electronically, maybe they will accept a ps document compressed with zip? You can use a plotting program other than gnu-plot - pl-plot for eg also has octave bindings (which is how I use gnu-plot). However: I just run gnu-plot outputs through GIMP > filter > enhance > anti-alias. Also good for labeling them in a nice font, and resizing (smart enlarge or use the standard interpolation). If you have lots, then you'll want script-fu or just write a shell-script for image-magick. |
| Dec3-11, 06:02 PM | #12 |
|
|
You could also try converting the image from .eps to .png with ImageMagick (sudo apt-get install imagemagick should work for Debian-based distros). In a terminal:
Code:
convert -density 300 image.eps image.pdf Increasing the image density should increase quality at the expense of a larger image size. |
| Dec3-11, 08:25 PM | #13 |
|
|
I don't use pdflatex, partly because of the lack of .eps support, and partly because i am comfortable with the latex -> dvips -> ps2pdf script that I use.
I'd prefer keep the [original] vector-graphics, rather than converting it to a raster format, then including that alternate file. |
| Dec3-11, 08:40 PM | #14 |
Recognitions:
|
You need to indetsand the difference between bitmap graphics and vector graphics here.
If you want to preserve "high quality" graphics when you to scale them to any size, you need vector graphics which defines each line by the "exact" coordinates of its end points, not bitmap graphics which defines a rectangular grid of pixels. When you scale bitmap graphics, the pixels just get bigger. When you scale vector graphics, the software "re-draws" the lines at the new scale to make the best use of the screen or printer resolution. PS, EPS, and PDF files can contain either bitmap or vector graphics, so you need to make sure that when you convert PS or EPS to a PDF you don't "accidentally" convert vector graphics into a bitmap. Somebody said "PDF uses lossy compression". Again that is only partly true - PDF can use either lossy or lossless compression, or no compresssion at all. The bottom line is that the EPSTOPDF program that comes with most versions of TeX does the conversion right. If the EPS file is vector graphics from GNUPLOT, the PDF will contain the exact same vector graphics. Other file conversion programs might do it wrong, or have the options that let you choose whether to do it right or wrong (but why bother, since EPSTOPDF doesn't have any options, and does it right). PNG is a bitmap graphics format with lossless compression. so it will work fine providing you don't want to scale the images. Otherwise, unless you have very complex plots from GNUPLOT, there's unlikely to be any advantage in terms of file size in using PNG rather than EPS and PDF. |
| Dec3-11, 08:44 PM | #15 |
|
Recognitions:
|
Well fair enough - in post #4, it was a bit unclear what you were doing to what.
It started out looking like you converted some image to pdf for inclusion into your document. The sort answer is "yes - but..." When other suggestions for post-processing were suggested, you respond: You could try plplot instead, or use the scilab plotting library. Or shell out for a commercial math-script engine like mathematica or matlab. |
| Dec3-11, 09:07 PM | #16 |
|
Recognitions:
|
dvipdf is the conversion utility used - iirc it does not support FlateEncode?
I suppose he should also use dvipdfm instead of dvipdf, supports flate, his text would look better too. Not found how to flag this on CLI, though the -z option sets the compression ratio. afaik the default is still DCTEncode Instead you have to open up your .eps file in a text editor and insert the following after the end of the "%" commented area at the beginning of the file: Code:
systemdict /setdistillerparams known {
<< /AutoFilterColorImages false /ColorImageFilter /FlateEncode >> setdistillerparams
} if
Those programs have a GUI to select the PDF options and it defaults to lossless. Doesn't convert all that nicely into OO fonts though, probably have to fiddle with the cli options. One can also export directly from Lyx, never tried. Rasterizing images is the recommended "best practice" where file-size is important. ------------------------------------- references: http://electron.mit.edu/~gsteele/pdf/ http://gaspra.kettering.edu/dvipdfm/dvipdfm-0.12.4.pdf |
| Dec4-11, 03:46 AM | #17 |
|
|
i don't say this:
"I'd prefer keep the [original] vector-graphics, rather than converting it to a raster format, then including that alternate file." i'm dirac68!
|
| New Reply |
| Thread Tools | |
Similar Threads for: quality graph with gnuplot and latex
|
||||
| Thread | Forum | Replies | ||
| GNUPlot generated EPS figure in latex | Math & Science Software | 4 | ||
| Gnuplot and Latex | Math & Science Software | 15 | ||
| graph on Latex | Engineering, Comp Sci, & Technology Homework | 0 | ||
| How to graph in Latex ? | Computing & Technology | 10 | ||
| LaTeX: Drawing Coxeter/Dynkin graph | Linear & Abstract Algebra | 2 | ||