TeX - LaTeX Asked on August 1, 2021
My end goal is to plot a color-filled contour plot of my data. The closest I have been is to generate a surf
with shader = interp
(which is not exactly what I wanted, but is actually good enough). My figure so far looks like:
The problem is that I had to fill all the region I dont want to plot with zeros. This also causes the problem that it creates a fake yellow halo around the edge because it interpolates between the actual value I have and the 0 I had to put next to it.
The data I am using is complete data.
My code so far is:
documentclass[11pt]{article}
usepackage[top=2.54cm, bottom=2.54cm, left=2.75cm, right=2.75cm]{geometry}
usepackage{float}
usepackage{subcaption}
usepackage{pgfplots}
usepackage{amsmath}
begin{document}
begin{figure}[H]
begin{tikzpicture}
begin{axis}
[
width=0.335paperwidth,
xlabel = Volts,
ylabel = Time,
view={0}{90},
only marks,
colorbar,
colorbar style ={width = 6}
]
addplot3 [surf,shader=interp] table[x index =0,y index=1,z index=2]{Ekicks.txt};
end{axis}
end{tikzpicture}
end{figure}
end{document}
The original data I want to plot, without all those zeros I dont need is clean data.
EDIT
Just to be clear, the problem is not that I had to fill the empty space with zeros, I am OK with that. The actual problem is the yellow halo that is generated around the edge, which is due to my zeros instead of the actual data.
EDIT 2
So I have been able to make some progress, and I have found a way to generate a filled contour plot using pgfplots. My new result looks like this, which is almost exactly what I want:
begin{tikzpicture}
begin{axis}
[
width=0.335paperwidth,
xlabel = Volts,
ylabel = Time,
view={0}{90},
only marks,
colorbar,
colorbar style ={width = 6}
]
addplot3[contour filled={number=40}]
table[x index =0,y index=1,z index=2]{Ekicks.txt};
end{axis}
end{tikzpicture}
My problem is that I still need to have a complete mesh. Does anybody know how I could just plot the values I need? Or how can I work around this, something like force all 0 to white, while all the other colors remain the same?
When you indicate your absent data with nan
instead of 0
you can ask pgfplot
to jump
over these data points instead of discard
ing them using the unbounded coords
key. This gives you a better visual representation of your actual data. With the downside that you do not have an extrapolation into the undetermined area, resulting in a ragged boundary.
documentclass{article}
usepackage{pgfplots}
begin{document}
begin{tikzpicture}
begin{axis}[
width=.7linewidth,
xlabel={Potential in Volt},
ylabel={Time},
view={0}{90},
colorbar,
unbounded coords=jump
] addplot3 [
surf,
shader=interp,
] table [
x index=0,
y index=1,
z index=2,
]{plot.dat};
end{axis}
end{tikzpicture}
end{document}
The resulting plot look like this:
Answered by Jan Hajer on August 1, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP