您知道在绘制二维图时如何获取以下星号标记吗?
这是我尝试过的:
\documentclass[border=10pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.9}
\usepackage{pgfplots}
\usepackage{subcaption}
%\usepackage{subfig}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{.5\textwidth}
\begin{tikzpicture}
\begin{axis}[
width=\linewidth,
line width=0.5,
grid=major, % Display a grid
tick label style={font={\tiny }},
legend style={nodes={scale=0.5, transform shape}},
label style={font={\tiny }},
legend image post style={},
grid style={white},
xlabel={$L$},
ylabel={RMSE},
y tick label style={
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=2
},
legend style={at={(1,0.95)}, anchor=north east, draw=none, fill=none},
]
\addplot[yellow!70!black,mark=o] table[x expr=\coordindex,y index=0] {
1.10513572361827
1.01208437057981
0.982129141362504
0.965535272773208
0.957525450047405
0.950991908467125
0.946662138047365
0.943677368384648
0.940827823053617
0.93852695585576
0.937338147322294
0.936376782449026
0.935476555754726
0.934912595379137
0.934178228940874
0.933667194443903
0.933013501708987
0.93258158463199
0.932380922764795
0.932389541141296
0.932133711215744
0.931961231250164
0.931738224344107
0.931468313557695
0.931422476255418
0.931391659490055
0.931455259106802
0.93149001089855
0.931437474580863
0.931450423300504
0.931455524207492
};
\addlegendentry{Pearson}
\addplot[black,mark=star] table[x expr=\coordindex,y index=0] {
1.10719721735896
1.01582510540871
0.985098421134354
0.96786252360382
0.958886724738097
0.952042896687217
0.947384236080908
0.944073525331402
0.942432710350078
0.941273030120187
0.939938038398727
0.939550221948232
0.938367614513753
0.937633178953075
0.937095821198273
0.936939991272534
0.936277616991041
0.936242747915614
0.935844591009396
0.935483558286952
0.935277656644467
0.935123081220845
0.93485985632522
0.934528594943281
0.934930752987058
0.935051236286854
0.935076947538366
0.934886531636357
0.934947666897746
0.935073906674002
0.935157289426046
};\addlegendentry{Cosin}
\end{axis}
\end{tikzpicture}
\subcaption{}
\end{subfigure}
\begin{subfigure}[b]{.5\textwidth}
\begin{tikzpicture}
\begin{axis}[
width=\linewidth,
line width=0.5,
grid=major, % Display a grid
tick label style={font={\tiny \normalsize}},
legend style={nodes={scale=0.5, transform shape}},
label style={font={\tiny }},
legend image post style={},
grid style={white},
xlabel={$L$},
ylabel={RMSE},
y tick label style={
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=2
},
legend style={at={(1,0.95)}, anchor=north east, draw=none, fill=none},
]
\addplot[yellow!70!black, mark=*] table[x expr=\coordindex,y index=0] {
1.10044666987188
0.999866628197923
0.962963949342376
0.943403150588027
0.931529691648424
0.924045339875979
0.918468987434381
0.913649154735605
0.911157563271859
0.908218682496785
0.906511033860998
0.90443746348175
0.903400003992971
0.902483106259459
0.901182138357611
0.901091293199105
0.899933357494439
0.900063989150366
0.899211759220085
0.898987646719118
0.898646916828567
0.898417264469362
0.898459860253319
0.897422113091948
0.897511433364885
0.897719097814211
0.897468138957815
0.896900763109816
0.896830721469015
0.896639819945792
0.896921589458794
0.896692907982105
0.896299668842855
0.896548805770678
0.896705444236237
0.896480855030312
0.896121426498849
0.896576004074635
0.896724593958936
0.896074079674064
};
\addlegendentry{Pearson}
\addplot[black,mark=diamond*] table[x expr=\coordindex,y index=0] {
1.1004034632523
0.998981366476003
0.964639819737259
0.9444588045967
0.934183872252177
0.926891588816588
0.920490355844599
0.916942125511546
0.914143090761063
0.91128589816521
0.909182330912049
0.908232246881679
0.906636708328323
0.905496628641986
0.904497783904894
0.903924914963062
0.902914066101777
0.903344661657377
0.902240953590319
0.901749031200971
0.901834063495761
0.901292603319992
0.90158539067463
0.90035948553436
0.900803164231954
0.900580586971413
0.900133521878354
0.900192476497936
0.899895224347253
0.900483176538678
0.900294084681683
0.899855113311963
0.900250507629163
0.899975977846179
0.899925759050512
0.90002961631342
0.900017002057276
0.900060834589157
0.899758520687127
0.900630302682763
};\addlegendentry{Cosine}
\end{axis}
\end{tikzpicture}
\subcaption{}
\end{subfigure}
\end{figure}
\end{document}
答案1
例如你可以这样做
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes.geometric}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfdeclareplotmark{mystar}{
\node[star,star point ratio=2.25,minimum size=6pt,
inner sep=0pt,draw=black,solid,fill=red] {};
}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[mark=mystar,red,dashed] coordinates {(0,0) (3,4) (4,1)};
\end{axis}
\end{tikzpicture}
\end{document}