2

I want to plot some data with gnuplot, but instead of using a regular key (or legend), I want to add images related to the source of the data. As an example, imagine that I'm plotting some data of iOS vs Android, and I want to add the logos instead of the names to the key. This plot would then included into a LaTeX document. My script looks similar to this.

#!/usr/bin/gnuplot -persist
set terminal epslatex size 6in,4in color dashed
set output 'apple-vs-android.tex'
set key bottom spacing 2 maxrows 1 width 8 at first 2000,175

set tics out mirror
unset x2tics
unset y2tics
set xlabel 'Year'
set ylabel 'Users'

plot "apple.dat"   u 1:2 w l        lt 1  lc 0 notitle smooth csplines,\
     "android.dat" u 1:2 w lp pt 12 lt 3  lc 0 notitle smooth csplines,\
     "apple.dat"   u 1:2 w p  pt 2        lc 0 notitle,\
     "android.dat" u 1:2 w p  pt 12       lc 0 notitle,\
     "apple-logo.png" binary filetype=png origin=(1960, 165) dx=1./10 dy=1./220000 with rgbimage notitle,\
     "android-logo.png" binary filetype=png origin=(1995, 165) dx=1./10 dy=1./220000 with rgbimage notitle,\
     -10 w lp pt 2  lt 1 lc 0 t " ",\
     -10 w lp pt 12 lt 3 lc 0 t " "

The last two lines are the only entries with titles (empty), just to add something into the key, and the logos would be positioned close to them, to identify the series. The actual values on the script (origin, dx, dy, key position) would depend on the size of the logo images and the data plotted. With my images and data, I tweaked the values and it looks fine.

The thing is that I have an SVG image with my logos. From it I can create a vectorial EPS instead of a raster PNG. Is there any way where I can import an EPS image within gnuplot, without manually editing neither the EPS code nor the .tex generated by gnuplot with the epslatex terminal?

Thanks

3
  • 1
    possible duplicate of Gnuplot: is there a way to add small gif icon on the plot? Commented Dec 10, 2014 at 14:45
  • Thanks for the comment. The \includegraphics label is clever, and could also be used for vector graphics Commented Dec 10, 2014 at 15:32
  • 1
    That method together with the epslatex is pretty much the only way (besides using other TeX-related terminals) to include vector graphics with gnuplot without postprocessing. Commented Dec 10, 2014 at 19:13

1 Answer 1

2

gnuplot is not an image manipulation program, but there are workarounds. There are ways to include raster graphics via multiplot. The method outlined in my second link (using the epslatex terminal) should work for .eps graphics as well.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, I guess you meant the first link. The multiplot allows better control that the method I used. Thanks for the tip. The \includegraphics as label, as posted here is also very clever. Neither is what I wanted, but probably I'm overstretching the capabilities of gnuplot. As you said, it's not an image manipulation program
@phollox, I actually meant to link to the article you mentioned! I will update my answer. I think that the \includegraphics command should let you include either raster or vector images.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.