
我正在嘗試繪製通過通道測量的探頭的速度數據。
目標是一個橫跨測量點的表面,並根據速度值 (v) 著色並從頂部查看(就像“顏色圖”?)。包括這些點之間的陰影。經過一天的嘗試,我得到的最佳結果如下。點之間的陰影仍然缺失。
當替換參數時,addplot3
情況surf
會變得更糟。
\documentclass{article}
\usepackage{pgfplots, filecontents}
\begin{filecontents*}{04_v_plot.csv}
depth,column,v
0.05,0.025,3.797153190429337
0.1,0.025,3.726861900740809
0.15,0.025,3.5359111045962095
0.2,0.025,3.4128410835129053
0.25,0.025,3.140235925631795
0.05,0.1,4.243357377017983
0.1,0.1,4.1459069835908196
0.15,0.1,3.9166226281025893
0.2,0.1,4.106142900384007
0.25,0.1,3.4708819672783275
0.05,0.175,4.132121899523459
0.1,0.175,3.768785853709482
0.15,0.175,3.345251163711442
0.2,0.175,3.2543256435843415
0.25,0.175,2.7823975289356344
\end{filecontents*}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
xlabel={Horizontal position},
ylabel={Depth},
colorbar,
y dir=reverse,
ymin=0,
ymax=0.3,
xmin=0,
xmax=0.2,
view={0}{90},
]
\addplot3+[scatter, only marks] table[x=column,y=depth,z=v,col sep=comma]{04_v_plot.csv};
\end{axis}
\end{tikzpicture}
\caption{Velocities at positions}%
\end{figure}
\end{document}
我重新排列了原始 csv 中的資料:
depth,A,B,C
0.05,3.797153190429337,4.243357377017983,4.132121899523459
0.1,3.726861900740809,4.1459069835908196,3.768785853709482
0.15,3.5359111045962095,3.9166226281025893,3.345251163711442
0.2,3.4128410835129053,4.106142900384007,3.2543256435843415
0.25,3.140235925631795,3.4708819672783275,2.7823975289356344
是否可以讀取原始 csv 檔案並繪製資料?
答案1
Asymptote
解決方案:
// csv-colormap.asy
//
// run
// asy csv-colormap.asy
//
// to get a standalone image in csv-colormap.pdf
//
settings.tex="pdflatex";
size(12cm,12cm);
import graph;
import palette;
import colorbrewer;
import fontsize;defaultpen(fontsize(8pt));
texpreamble("\usepackage{lmodern}"+"\usepackage{amsmath}"
+"\usepackage{amsfonts}"+"\usepackage{amssymb}");
file fin=input("04_v_plot.csv").csv();
string[] s=fin.line(); // skip the title line
real[][] A=fin;
A=transpose(A);
real[] x=A[0];
real[] y=A[1];
real[] z=A[2];
pen[] Palette=Blues9;
picture bar;
bounds range=image(x,y,z,Palette);
palette(bar,rotate(90)*"Velocity",range,(0,0),(0.5cm,5.3cm)
,Right,Palette,PaletteTicks("$%+#.1f$"));
add(bar.fit(),point(E),30E);
xaxis("Horizontal position",BottomTop,LeftTicks(Step=0.05,step=0.01),above=true);
yaxis("Depth",LeftRight,RightTicks(Step=0.05,step=0.01),above=true);
請注意,此程式碼使用調色板Blues9
來自
Colorbrewer.asy,它提供了
Cynthia Brewer 教授的配色方案
作為漸近線的筆數組。當然,它可以替換為任何其他合適的調色板。