2

This question already has an answer here:

I'm using matlab2tikz to export imagesc figures into TikZ/pgfplots code. This process gives me a TikZ file and a rasterized png version of the image with colours matching the colourbar at the time of execution.

The problem is that the resulting image is upside-down and displays a blurred colormap, as shown below.

This is the tikzpicture:

while this is how it should look like (screenshot from Matlab R2013a):

The file produced by matlab2tikz is as follows

\begin{tikzpicture}

\begin{axis}[%
width=5.296in,
height=4.747in,
at={(1.01in,0.641in)},
scale only axis,
point meta min=1,
point meta max=8.715,
axis on top,
separate axis lines,
every outer x axis line/.append style={black},
every x tick label/.append style={font=\color{black}},
xmin=0.05,
xmax=1.05,
every outer y axis line/.append style={black},
every y tick label/.append style={font=\color{black}},
y dir=reverse,
ymin=0.05,
ymax=1.05,
axis background/.style={fill=white},
colormap/jet,
colorbar,
colorbar style={separate axis lines,every outer x axis line/.append style={black},every x tick label/.append style={font=\color{black}},every outer y axis line/.append style={black},every y tick label/.append style={font=\color{black}}}
]
\addplot [forget plot] graphics [xmin=1.05,xmax=0.05,ymin=1.05,ymax=0.05] {ainf-1.png};
\end{axis}
\end{tikzpicture}%

while the Matlab code that generates the figure is

figure
imagesc([1 0.1], [1 0.1], mean_e_range)
colorbar

My primary concern is how to sharpen the blurred surface of the colormap. As for the other problem, at worst I can plot the upside-down figure in Matlab and then get the upside-down TikZ version of such upside-down figure, which is the final picture I want.

marked as duplicate by Stefan Pinnow, Zarko tikz-pgf Nov 3 '16 at 21:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Regardless, please don't use that colormap. tex.stackexchange.com/questions/228197/… – percusse Jan 15 '16 at 14:52
  • I believe this is actually more a question for matlab2tikz since that script generates the bitmap graphics in question. – Christian Feuersänger Jan 15 '16 at 18:37
  • Aside from that, it sounds a lot like a duplicate of tex.stackexchange.com/a/286925/1537 . You can easily import the data matrix mean_e_range into \addplot[matrix plot] as outlined in the linked answer. Section "7.2.1 Importing Mesh Data From Matlab To PGFPlots" of the pgfplots manual shows how to export + import the data. – Christian Feuersänger Jan 15 '16 at 18:39
  • @percusse I will follow your suggestion. After reading your comment, I googled and found many valid reasons against the jet colormap. – AAG Jan 16 '16 at 18:09
  • @ChristianFeuersänger Thank you. I imported the data matrix manually - that is, without matlab2tikz. I had read the answer you linked to before posting my question, but without realising it could be useful to solve my problem. – AAG Jan 16 '16 at 18:18