Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
824 views
in Technique[技术] by (71.8m points)

plot - Problem plotting curve with smooth option

this is twice the same graph, except one is smoothed. If you compile it, you will see.

documentclass[
]{scrreprt}     
usepackage[backend=biber]{biblatex} 
usepackage{pgfplots}
usepackage{tikz}
egin{document}

egin{figure*}[!ht]
centering  
egin{tikzpicture}
egin{axis}[%
scatter/classes={%
1={mark=diamond*,draw=black},
0={mark=o,draw=black}},
yticklabels={},ytick style = {draw=none},  xticklabels={},xtick style = {draw=none},
xmin=0,
xmax=200,
ymin=0,
ymax=11,
width=12cm,
height=7cm]
addplot[smooth,black]
coordinates{
            (0,10)
            (10,1)
            (200,0.1)
            };
            
addplot[ dashed, black]
        coordinates{
            (0,10)
            (10,1)
            (200,0.1)
            };
end{axis}  
end{tikzpicture}   
end{figure*}
end{document}

What I actually trying to achieve is that the second data point gives a smooth curve. But using option smooth as you can see absolutely doesn't do the job here. I tried with many more data points but nothing worked, this just gave me weird results. Also the approximation from the second to the last data point doesn't work as intended.

If you ask how it actually should look like, google Goodfellow generalization. I want to draw this comparison between training and generalization error.

Every advice is very much appreciated!

question from:https://stackoverflow.com/questions/65852459/problem-plotting-curve-with-smooth-option

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can adapt the level of smoothness with the tension parameter:

documentclass[
]{scrreprt}     
usepackage[backend=biber]{biblatex} 
usepackage{pgfplots}
usepackage{tikz}
egin{document}

egin{figure*}[!ht]
centering  
egin{tikzpicture}
egin{axis}[%
scatter/classes={%
1={mark=diamond*,draw=black},
0={mark=o,draw=black}},
yticklabels={},ytick style = {draw=none},  xticklabels={},xtick style = {draw=none},
xmin=0,
xmax=200,
ymin=0,
ymax=11,
width=12cm,
height=7cm]
addplot[smooth,black,tension={0.15}]
coordinates{
            (0,10)
            (10,1)
            (200,0.1)
            };
            
addplot[ dashed, black]
        coordinates{
            (0,10)
            (10,1)
            (200,0.1)
            };
end{axis}  
end{tikzpicture}   
end{figure*}
end{document}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...