如何在 pgfplots 中将所有函数绘制为实线而不是虚线

如何在 pgfplots 中将所有函数绘制为实线而不是虚线

这是我的代码。

\documentclass[13pt,a4paper]{scrartcl}

\usepackage[x11names]{xcolor}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.12}
\usetikzlibrary{intersections}

\begin{document}

\begin{center} 
\begin{tikzpicture}[scale=1.2]
  \begin{axis}[axis lines=middle,xmin=-0.5,xmax=180,ymin=-0.5,ymax=150,
        x post scale=1.5,
        y post scale=2]
        \addplot+[no marks,domain=0:120,samples=200, ultra thick, color=DarkOliveGreen4] {x} node[right,pos=1] {45}; 
        \addplot+[no marks,domain=50:150,samples=200, ultra thick, color=Gold3] {-0.25*x+112.5} node[below] {$\pi = 20\%$};
        \addplot+[no marks,domain=50:150,samples=200, ultra thick, color=gray] {-0.66667*x+133.333} node[below] {$\pi = 40\%$};
        \addplot+[no marks,domain=50:100,samples=200, ultra thick, color=Gold3] {-1.5*x+175} node[below] { $\pi = 60\%$};
        \addplot+[domain=70:120,samples=200, color=DodgerBlue2, mark=none, ultra thick] {((9.4868-0.2*sqrt(x))/0.8)^2};
        \addplot+[domain=55:120,samples=200, color=DodgerBlue2, mark=none, ultra thick] {((8.3666-0.6*sqrt(x))/0.4)^2}; 
        \addplot+[domain=55:120,samples=200, color=DodgerBlue2, mark=none, ultra thick] {((8.944271-0.4*sqrt(x))/0.6)^2}; 
        \filldraw (50,100) circle (2.5pt)node[right,font=\tiny] {}; 
        \filldraw (90,90) circle (1.5pt)node[right,font=\tiny] {}; 
        \filldraw (80,80) circle (1.5pt)node[right,font=\tiny] {}; 
        \filldraw (70,70) circle (1.5pt)node[right,font=\tiny] {}; 
  \end{axis}
\end{tikzpicture}
\end{center}

\end{document}

这是图片。我喜欢所有线条都保持实线,只要我不要求其他样式。有一些类似的问题。没有一个能解决我的问题。

在此处输入图片描述

答案1

Torbjørn T.`s回答

pgfplots有一个样式列表,它会逐一检查每个样式 \addplot。有多个列表可供选择,请参阅第 4.7.7 节循环列表 - 控制线型的选项在手册中,但您也可以定义自己的。

这里定义了一个空列表。

A

\documentclass[13pt,a4paper]{scrartcl}

\usepackage[x11names]{xcolor}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.12}
\usetikzlibrary{intersections}
    
\begin{document}
    
    \begin{center} 
        \begin{tikzpicture}[scale=1.2]
            \begin{axis}[axis lines=middle,xmin=-0.5,xmax=180,ymin=-0.5,ymax=150,
                x post scale=1.5,
                y post scale=2,
                cycle list ={} % added <<<<<<<<<<<<<<<<<<<
                ]
                \addplot+[no marks,domain=0:120,samples=200, ultra thick, color=DarkOliveGreen4] {x} node[right,pos=1] {45}; 
                \addplot+[no marks,domain=50:150,samples=200, ultra thick, color=Gold3] {-0.25*x+112.5} node[below] {$\pi = 20\%$};
                \addplot+[no marks,domain=50:150,samples=200, ultra thick, color=gray] {-0.66667*x+133.333} node[below] {$\pi = 40\%$};
                \addplot+[no marks,domain=50:100,samples=200, ultra thick, color=Gold3] {-1.5*x+175} node[below] { $\pi = 60\%$};
                \addplot+[domain=70:120,samples=200, color=DodgerBlue2, mark=none, ultra thick] {((9.4868-0.2*sqrt(x))/0.8)^2};
                \addplot+[domain=55:120,samples=200, color=DodgerBlue2, mark=none, ultra thick] {((8.3666-0.6*sqrt(x))/0.4)^2}; 
                \addplot+[domain=55:120,samples=200, color=DodgerBlue2, mark=none, ultra thick] {((8.944271-0.4*sqrt(x))/0.6)^2}; 
                \filldraw (50,100) circle (2.5pt)node[right,font=\tiny] {}; 
                \filldraw (90,90) circle (1.5pt)node[right,font=\tiny] {}; 
                \filldraw (80,80) circle (1.5pt)node[right,font=\tiny] {}; 
                \filldraw (70,70) circle (1.5pt)node[right,font=\tiny] {}; 
            \end{axis}
        \end{tikzpicture}
    \end{center}
    
\end{document}

可以统一所有的风格,并简化代码。

        \begin{tikzpicture}[scale=1.2]
            \begin{axis}[axis lines=middle,xmin=-0.5,xmax=180,ymin=-0.5,ymax=150,
                x post scale=1.5,
                y post scale=2,
                cycle list ={no marks,samples=200, ultra thick\\} % added <<<<<<<<<<<<<<<<<<<
                ]
                \addplot+[domain=0:120, color=DarkOliveGreen4] {x} node[right,pos=1] {45}; 
                \addplot+[domain=50:150, color=Gold3] {-0.25*x+112.5} node[below] {$\pi = 20\%$};
                \addplot+[domain=50:150, color=gray] {-0.66667*x+133.333} node[below] {$\pi = 40\%$};
                \addplot+[domain=50:100, color=Gold3] {-1.5*x+175} node[below] { $\pi = 60\%$};
                \addplot+[domain=70:120, color=DodgerBlue2] {((9.4868-0.2*sqrt(x))/0.8)^2};
                \addplot+[domain=55:120, color=DodgerBlue2] {((8.3666-0.6*sqrt(x))/0.4)^2}; 
                \addplot+[domain=55:120, color=DodgerBlue2] {((8.944271-0.4*sqrt(x))/0.6)^2}; 
                \filldraw (50,100) circle (2.5pt)node[right,font=\tiny] {}; 
                \filldraw (90,90) circle (1.5pt)node[right,font=\tiny] {}; 
                \filldraw (80,80) circle (1.5pt)node[right,font=\tiny] {}; 
                \filldraw (70,70) circle (1.5pt)node[right,font=\tiny] {}; 
            \end{axis}
        \end{tikzpicture}

相关内容