我試圖以在座標處添加更大的圓圈標記的方式突出顯示顏色圖上的數據點(3.6,47)
。在此範例中(請參見下圖),我只是在此座標處添加了額外的點,並選擇了接近我所看到的顏色。我想知道是否有一種方法可以添加與顏色圖中完全相同的顏色的完全相同的點。
這是我使用的程式碼
\documentclass{standalone}
\usepackage{amsmath,amssymb}
\usepackage{graphicx}
\usepackage{dcolumn}
\usepackage{bm}
\usepackage[numbers,super,comma,sort&compress]{natbib}
\usepackage{tikz}
\usetikzlibrary{tikzmark,patterns}
\usetikzlibrary{arrows,arrows.meta,shapes.arrows,shapes.geometric}
\tikzset{>=latex}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepgfplotslibrary{fillbetween}
\usepackage{xcolor}
\definecolor{dgreen}{rgb}{0.0, 0.5, 0.0}
\pgfplotsset{
colormap={greenyellow}{rgb255(0cm)=(0,128,0); rgb255(1cm)=(255,255,0)}
}
\pgfkeys{/pgf/number format/.cd,1000 sep={}}
\pgfplotsset{compat=newest,
every axis x label/.append style={black},
every axis y label/.append style={black},
every major grid/.append style={gray!50,line width=0.4pt},
every minor grid/.append style={gray!50,line width=0.4pt},
every major tick/.append style={black,line width=0.6pt},
every minor tick/.append style={black,line width=0.6pt},
every x tick label/.append style={black},
every y tick label/.append style={black}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[colormap/greenyellow,
enable tick line clipping=false,
axis on top=true,
width=8cm,
height=6cm,
axis line style={line width=0.6pt},
x label style={at=(ticklabel cs:0.5),anchor=near ticklabel},
xmin=0,xmax=5,
xtick={0,1,...,5},
xtick pos=bottom,
xtick align=outside,
xlabel={$x$},
y label style={at=(ticklabel cs:0.5),anchor=near ticklabel},
ymin=0,ymax=80,
ytick={0,20,...,80},
ytick pos=left,
ytick align=outside,
ylabel={$y$}
]
\addplot [scatter,mark=*,mark options={mark size=1},samples=200,domain=0:5] {100*((1/(-0.088540*x+1))-1)};
\addplot [only marks,mark=*,mark options={mark size=3,white,line width=0.8pt,fill=dgreen}] coordinates {(3.6,47)};
\end{axis}
\end{tikzpicture}
\end{document}```
答案1
您可以繪製單一座標的散佈圖。我刪除了所有不必要的套件和選項。
\documentclass{standalone}
\usepackage{pgfplots}
\pgfkeys{
/pgf/number format/.cd,
1000 sep={}
}
\pgfplotsset{
compat=newest,
every major grid/.append style={gray!50,line width=0.4pt},
every minor grid/.append style={gray!50,line width=0.4pt},
every major tick/.append style={black,line width=0.6pt},
every minor tick/.append style={black,line width=0.6pt},
colormap={greenyellow}{rgb255(0cm)=(0,128,0); rgb255(1cm)=(255,255,0)}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
colormap/greenyellow,
axis on top=true,
width=8cm,
height=6cm,
axis line style={line width=0.6pt},
xmin=0,xmax=5,
xtick pos=bottom,
xtick align=outside,
xlabel={$x$},
ymin=0,ymax=80,
ytick pos=left,
ytick align=outside,
ylabel={$y$}
]
\addplot [scatter,mark=*,mark options={mark size=1},samples=200,domain=0:5] {100*((1/(-0.088540*x+1))-1)};
\addplot [scatter,mark=*,mark options={mark size=3}] coordinates {(3.6,{100*((1/(-0.088540*3.6+1))-1)})};
\addplot [scatter,mark=*,mark options={mark size=3}] coordinates {(1.5,{100*((1/(-0.088540*1.5+1))-1)})};
\end{axis}
\end{tikzpicture}
\end{document}