pgfplots: การเปลี่ยนรูปร่างของเครื่องหมายขีดแกน

Aug 20 2020

ฉันจะใช้เครื่องหมายขีดที่มีรูปร่างต่างกันบนแกนเช่นวงกลมได้อย่างไร ฉันได้ลองตั้งค่ารูปแบบเห็บเป็นshape=circleและสิ่งที่คล้ายกันแล้ว แต่ดูเหมือนว่าจะไม่มีผล

\documentclass{minimal}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[tick style={shape=circle}]
    \addplot[samples=300,domain=0:1,thick]{x^2};
\end{axis}
\end{tikzpicture}
\end{document}

คำตอบ

2 Ross Aug 20 2020 at 12:30

คุณสามารถลบเครื่องหมายถูกเริ่มต้นxtick style={draw=none}และพล็อตวงกลมบนแกน x ด้วย\addplotคำสั่งอื่นที่ใช้mark=oเพื่อสร้างวงกลม

\documentclass[border=3pt]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
%   tick style={shape=circle},
   xtick style={draw=none}, % <-- removing default tick marks
   ymin=-0.1                % <-- define ymin
   ]
    \addplot[samples=300,domain=0:1,thick]{x^2};
    \addplot[draw=none,mark=o] coordinates
    {(0,-0.1) (0.2,-0.1) (0.4,-0.1) (0.6,-0.1) (0.8,-0.1) (1,-0.1)}; % <-- add circles by plotting marks at y=-0.1
\end{axis}
\end{tikzpicture}
\end{document}