Samstag, 17. Januar 2015

plot color of data point with z-value

To plot a x,y,z data file with the z-value being the color value of the x,y data point use "with linespoints palette" as following:

plot 'test.dat' u 1:2:3 with linespoints palette 

An example is shown below:

Donnerstag, 15. Januar 2015

gnuplot use figure with alpha channel

Sometimes it is desirable to plot data on top of a figure or a figure on top of a graph. In the latter case the figure has to be transparent so that the plotted data is still shown. This can be achieved via the "with rgbalpha" option as shown in the following:
plot "partly_transparent_figure.png" binary filetype=png  with rgbalpha

round numbers in tikz with pgfmath

To round numbers using pgfplots in the tikzpicture environment use \pgfmathparse to calculate the desired value and then print it to with \pgfmathprintnumber or print it to a variable with \pgfmathprintnumberto and use the optional parameter precision, as shown in the following:
\pgfmathparse{10.042/1.54}
\pgfmathprintnumberto[precision=2]{\pgfmathresult}{\value}
\value

Mittwoch, 17. Dezember 2014

layers in tikz in latex

To define a layer in tikz you would first in the preamble define a new layer with a defined name (here i chose "layer") and then set the order of the layers especially in comparison to the standard "main" layer.

\pgfdeclarelayer{layer}    % declare layer
\pgfsetlayers{layer,main}  % set the order of the layers (main is the standard layer)

in the plotting step you can then explicitly plot on a different layer by using the pgfonlayer environment

\begin{pgfonlayer}{layer}
      \draw[ultra thick] (0.0,0.0) -- ++ (1.0,0.0);
\end{pgfonlayer}

Freitag, 14. November 2014

latex trim image

to cut an image in latex you can simply use the trim option and then define then use the clip option as follow:

\includegraphics[trim={left low right top},clip]{./test.png}

Donnerstag, 23. Oktober 2014

Latex (tikz) emphasize part of graphic

http://tex.stackexchange.com/questions/181098/semitransparent-outside-clipped-region

gnuplot loop over all blocks in datafile

If you have a data file for gnuplot with indexable blocks (two blank lines between data blocks) e.g.:

0 1
1 2

0 1.5
1 2.5


0 2.0
2 3.0

and want to plot each plot individually but with the same plot command, you can simply use the gnuplot 4.6 stats function to get the number of blocks and loop over the blocks in a combined command:

#!/usr/bin/gnuplot

file="data.dat"
stats file

plot for [i=0:STATS_blocks-2] file index i w l ls i+1
PS: if you only have one blank line between data blocks you need to use the every command:
#!/usr/bin/gnuplot

file="data.dat"
stats file

plot for [i=0:STATS_blank] file every :::i::i w l ls i+1