I would like to make a plot of a function that has an overshoot of 25% and then settles with subtle oscillations at 100%. I would like to create it in one of the listed packages or in gnus case add on to PGFPlots. Unfortunately, I don't know the function I just have an image so I don't know how to start creating it.
[Tex/LaTex] TikZ, PGFPlots, or GNUplot: plotting a curve without the known function
gnuplotpgfplotstikz-pgf
Related Solutions
In principle pgfplots provides what you need. Especially the x coord trafo
section of the manual helps as Qrrbrbirlbel has mentioned.
Here is a very simple example:
\documentclass[tikz,12pt,preview]{standalone}
\usepackage{filecontents}
\begin{filecontents*}{transform.dat}
1 1
2 4
3 9
4 16
\end{filecontents*}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.8}
\usetikzlibrary{plotmarks,calc}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{
x coord trafo/.code={\pgfmathparse{#1^2}\pgfmathresult},
x coord inv trafo/.code={\pgfmathparse{#1}\pgfmathresult},
}
\begin{axis}[ylabel={$f(x)=x^2$},xlabel=$x^2$]
\addplot table {transform.dat};
\end{axis}
\end{tikzpicture}
\end{document}
Here the x-axis is transformed and the final result is a straight line again:
I don't have the full answer to my question but I'm one step closer to the solution.
One problem was that I didn't use \addplot3
in my second code example, but this didn't do the trick. I remembered the mesh/cols
(see pgfplots manual v1.11 Rev 1.11 in Section 4.6.2) option which has to be used for surface plots with pgfplots. So I used it:
\documentclass{scrbook}
\usepackage{graphicx, pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{colormap={myown}{color(0mm)=(red);
color(1mm)=(orange);
color(2mm)=(yellow);
color(5mm)=(green);
color(10mm)=(blue)}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={0}{90},
colorbar,
colormap name=myown,
colorbar style={scaled ticks=false},
faceted color=none, % remove lines between fields
xtick={2,3,...,11},
ytick={2,3,...,10},
]
\addplot3 [raw gnuplot,surf,mesh/cols=10] gnuplot {
plot 'data' matrix using 1:2:3 with image;
};
\end{axis}
\end{tikzpicture}
\end{document}
This results in this figure:
which is almost what I want. The data
file is provided in a matrix format like:
0.000352994 0.000742189 0.000634092 ...
0.001709539 0.000348077 0.000179216 ...
0.00379762 0.00071006 8.2598e-05 ...
...
But there are two problems remaining:
The ticks are not centred in relation to the value fields. This is obviously caused by the bigger problem, that this is plotted as an interpolation. So, actually the ticks are at the right place, but the colors of the fields are an interpolation between two values. This is the behaviour of pgfplots as I understand from the manual, but I thought the point of using
addplot3 [...] gnuplot [...] {...}
is to let gnuplot the work do? The figure shows now a 8x9 matrix butdata
contains a 9x10 matrix of value points, which I want to illustrate.
edit: As @Christian Feuersänger wrote in a comment to my question above a way around this problem is to add an extra dummy column and row, like it is mentioned Using pgfplots, how do I arrange my data matrix for a surface plot so that each cell in the matrix is plotted as a square?. So I modified my data structure like this
0.000352994 0.000742189 0.000634092 ... 1 0.001709539 0.000348077 0.000179216 ... 1 0.00379762 0.00071006 8.2598e-05 ... 1 ... 1 1 1 ...
and updated the number of cols with
mesh/cols=11
and got the following result:No I have the correct number of cells, but the ticks are still a problem. I know that I can shift the ticks and the ticklabels manually, but I hope there is a better way. ;-)
The second problem is the colouring given by the
colorbar
. Many values are close to zero. So because of the scale we don't see a structure even though there is one. I can reveal the structure by replacing the plot command withplot 'hilbert_preTime.dat' matrix using 1:2:(log($3)) with image;
but the colorbar ticks are showing weird values:
Actually I think these are the exponents of the logarithmic scale, but I really don't know how to fix this, since changing the colorbar scale with
colorbar style={ymode=log}
, results in an empty colorbar with these warnings from the pgfplots package:Ignoring illegal input argument ymin=-1.618e1: cannot apply log. Ignoring illegal input argument ymax=-3.94094e0: cannot apply log. the current plot has no coordinates (or all have been filtered away) You have an axis with empty range (in direction y). Replacing it with a default range and clearing all plots.
Thanks for any hints!
Best Answer
Just for a starting point. It is not a complete answer.