1

basically I have plot like this:

enter image description here

It looks bad because two reasons:

  1. The middle figure, five keys are overlapped with lines
  2. The 6 key in the third figure, even they are not overlapped, they are not horizontal, which is inconsistent with the above two figures.

I am tried to put the keys to outside the figure, say:

set key outside

However, as essentially I am writing a double-column paper (these figures are in one column), it makes the figures become too small...

enter image description here

I tried to manipulate the

set size ratio 0.35

But didn't get some good results.

I just want to represent the figure clear enough, while keeping these keys. Any though on how to do it?

I simplified my gnuplot script and copied it here:

set term pdf size 8,10 font "Arial,24"
set output "test.pdf"
set multiplot layout 3,1
set size ratio 0.35
set datafile separator ","
set offset 0, 0, 0, 0
set xtics norangelimit
set ytics nomirror
set termoption dashed
set key bottom right
set key horiz
set yrange [-5:1000]
set style data linespoints
set key vertical maxrows 5
plot 'plot/data.csv' using 1:xtic((int($0)%4)==0?sprintf("%d", $0*50):"") title   columnheader(1) pt 4 lw 1, \
'' using 2 title columnheader(2) pt 5 lw 4 ps .8 lc rgb "#4169E1", \
'' using 3 title columnheader(3) pt 6 lw 4 ps .8 lc rgb "#DAA520", \
'' using 4 title columnheader(4) pt 7 lw 4 ps .8 lc rgb "#FF7F50", \
'' using 5 title columnheader(5) pt 8 lw 4 ps .8 lc 7
plot 'plot/data.csv' using 6:xtic((int($0)%4)==0?sprintf("%d", $0*50):"") title columnheader(6) pt 4 lw 1, \
'' using 7 title columnheader(7) pt 5 lw 4 ps .8 lc rgb "#4169E1", \
'' using 8 title columnheader(8) pt 6 lw 4 ps .8 lc rgb "#DAA520", \
'' using 9 title columnheader(9) pt 7 lw 4 ps .8 lc rgb "#FF7F50", \
'' using 10 title columnheader(10) pt 8 lw 4 ps .8 lc 7
plot 'plot/data.csv' using 11:xtic((int($0)%4)==0?sprintf("%d", $0*50):"") title columnheader(11) pt 4 lw 1, \
'' using 12 title columnheader(12) pt 5 lw 4 ps .8 lc rgb "#4169E1", \
'' using 13 title columnheader(13) pt 6 lw 4 ps .8 lc rgb "#DAA520", \
'' using 14 title columnheader(14) pt 7 lw 4 ps .8 lc rgb "#FF7F50", \
'' using 15 title columnheader(15) pt 8 lw 4 ps .8 lc 7, \
'' using 16 title columnheader(16) pt 9 lw 4 ps .8 lc rgb "#7FFFD4"

I upload the data to my dropbox account. and shared it to the public.

10
  • Please provide a minimal working example (MWE) along with your full gnuplot code.
    – user11232
    Apr 9, 2015 at 2:35
  • @HarishKumar, OK, but it contains a large amount of data, in csv format.. How can I upload it..? Sorry this is the first time I use this tex site. Apr 9, 2015 at 2:40
  • Use filecontents and reduce the amount of data. If not possible, at least provide code. Data we can simulate.
    – user11232
    Apr 9, 2015 at 2:42
  • @HarishKumar, done! Hope it works! Apr 9, 2015 at 3:27
  • How is this related to TeX? This appears to be a gnuplot question. Are you using something like pgfplots, or just including the gnuplot result?
    – erik
    Apr 9, 2015 at 3:39

1 Answer 1

2

Some how I was not able to get your gnuplot code to get working. I didn't want to use your data here. Hence the following should give you some idea and serve as a starting point.

This approach uses pgfplots on the outer layer with raw gnuplot option and the gnuplot code is used inside for plotting the actual graph. Hence the legend position can be controlled by pgfplots. The normal way of doing this is by using

legend style={at={(.5,0.9)},anchor=north},  

where the parameters are changed at will. Another way is to name the legends and use \ref. The following code uses this approach. Additionally you can change the number of columns using

legend columns=4

and change the width using width key.

\documentclass{article}
\usepackage{pgfplots}

\pgfplotsset{compat=1.12}

\begin{document}
\noindent
\begin{tikzpicture}[baseline=(current bounding box.center)]
\begin{axis}[
width=0.8\linewidth,   %% adjust
xmin = 0,
xmax = 1.5,
ymin = 0,
ymax = 6.2831853072,
xlabel={$x$},
ylabel={$y$},
legend columns=2,   %%<---      change this to suit
legend to name=mylegend,
%legend style={at={(.5,0.9)},anchor=north},    %%<-- you can use this too if you want
]

\addplot +[no markers,
raw gnuplot,
thick,
blue,
] gnuplot {
    set contour base;
    set cntrparam levels discrete 0.003;
    unset surface;
    set view map;
    set isosamples 500;
    plot [0:2*pi] 5*sin(x);
};
\addlegendentry{some}
\addplot +[no markers,
raw gnuplot,
thick,
green,
] gnuplot {
    set contour base;
    set cntrparam levels discrete 0.003;
    unset surface;
    set view map;
    set isosamples 500;
    plot [0:2*pi] 3*sin(x);
};
\addlegendentry{some}
\addplot +[no markers,
raw gnuplot,
thick,
red,
] gnuplot {
    set contour base;
    set cntrparam levels discrete 0.003;
    unset surface;
    set view map;
    set isosamples 500;
    plot [0:2*pi] 2*sin(x);
};
\addlegendentry{some}
\addlegendentry{some}
\addplot +[no markers,
raw gnuplot,
thick,
orange,
] gnuplot {
    set contour base;
    set cntrparam levels discrete 0.003;
    unset surface;
    set view map;
    set isosamples 500;
    plot [0:2*pi] 2*sin(x);
};
\addlegendentry{some}
\end{axis}
\end{tikzpicture}
%%If you put \centering at the beginning and put a \par here the legends come to bottom of plot
\ref{mylegend}
\end{document}

enter image description here

Or... you may use only pgfplots for the entire graph.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .