如何取消绘图中的 ticks=none

如何取消绘图中的 ticks=none

你好,tikzpicture 专家。

我在抑制滴答声之后重新恢复滴答声时遇到了麻烦。

看看第二张图(具有可行区域的图)中,尽管我告诉 Latex 输出它,但所有的刻度标签都丢失了?

电流输出

谁能告诉我如何解除蜱虫抑制?

谢谢。

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{cancel}
\usepackage{pgfplots}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{amssymb}
\usepgfplotslibrary{fillbetween}
\newenvironment{tightcenter}{
\setlength\topsep{0pt}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
\definecolor{Elite}{RGB}{37,97,172}
First graph where I do not need ticks\\
\\
\pgfplotsset{every axis/.append style={
axis x line=middle,    % put the x axis in the middle
axis y line=middle,    % put the y axis in the middle
axis line style={<->}, % arrows on the axis
ticks=none,
width=10.5cm,
height=8cm
}}
\begin{tikzpicture}
\begin{axis}[
xmin=-0.5,xmax=5.7,ymin=-0.1,ymax=0.35,
xlabel={$t$(\text{min})},
ylabel={$d$(\text{m})},
yticklabel style={
    fill=white,
    %yshift=10pt,
},
xticklabel style={
    %xshift=10pt,
    fill=white
}
]
\addplot[thick,color=black,samples=100,domain=0:1] {0.25*x};
\addplot[thick,color=black,samples=100,domain=1:2.25] {0.25};
\addplot[thick,color=black,samples=100,domain=2.25:4.25] {-0.125*x+0.53125};
%\addplot[ultra thick,color=black,samples=100,domain=0:-0.4,->] {0};
\node [below] at (axis cs: +0.15,0){$O$};
\node [below] at (axis cs: 1,0){$1$};
\node [below] at (axis cs: 2.25,0){$2.25$};
\node [below] at (axis cs: 4.25,0){$4.25$};
\node [left] at (axis cs: 0,0.25){$100$};
%\node [below] at (axis cs: 7/3,-0.01){$\frac{7}{3}$};
%\node [left] at (axis cs: 0,0.5){$a$};
\draw[fill=black] (axis cs:0,0) circle (0.7mm);
\draw[fill=black] (axis cs:7/3,0.5) circle (0.7mm);
%\draw[fill=white] (axis cs:7/3,0) circle (0.7mm);
\draw[thick,dashed](axis cs:1,0) -- (axis cs:1,0.25);
\draw[thick,dashed](axis cs:2.25,0) -- (axis cs:2.25,0.25);
\draw[thick,dashed](axis cs:0,0.25) -- (axis cs:1,0.25);
%
\draw[thick,Elite](axis cs:2.25,0.25) -- (axis cs:3.1,0);
\node [Elite,below] at (axis cs: 3.31,0){$3.31$};
\end{axis}
\end{tikzpicture}\\\\
\\\\
Next graph is missing ticks hmm\\
\\
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
grid=major,
xmin=-1,
xmax=43,
ymin=-0.3,
ymax=5.2,
xtick={0,5,10,15,20,25,30,35,40,45},
ytick={0,1,2,3,4,5},
height=9cm,
width=12cm,
axis line style={shorten >=-10pt, shorten <=-10pt},
ylabel style={
anchor=south,
at={(ticklabel* cs:1.0)},
yshift=10pt
},
ylabel=\textit{y},
xlabel style={
anchor=west,
at={(ticklabel* cs:1.0)},
xshift=10pt
},
xlabel=\textit{x}
]
\addplot[thick,samples=100,domain=0:25] {5-1/5*x};
\addplot[thick,samples=100,domain=0:30] {4-2/15*x};
\addplot[thick,samples=100,domain=0:40] {8/5-1/25*x};
%
\addplot[name path=f0,thick,opacity=0,samples=100,domain=0:15] {5.2};
\addplot[name path=f1,thick,opacity=0,samples=100,domain=0:15] {5-1/5*x};
\addplot[name path=f01,thick,opacity=0,samples=100,domain=15:25.9] {5.2};
\addplot[name path=f2,thick,opacity=0,samples=100,domain=15:25.9] {4-2/15*x};
\addplot[name path=f02,thick,opacity=0,samples=100,domain=25.9:43] {5.2};
\addplot[name path=f3,thick,opacity=0,samples=100,domain=25.9:40] {8/5-1/25*x};
\addplot[name path=f4,thick,opacity=0,samples=100,domain=0:43] {5.2};
\addplot[name path=f5,thick,opacity=0,samples=100,domain=0:43] {0};
%
\addplot fill between[
of = f0 and f1,
soft clip={domain=0:40},
every even segment/.style  = {gray,opacity=.4}
];
\addplot fill between[
of = f01 and f2,
soft clip={domain=15:25.9},
every even segment/.style  = {gray,opacity=.4}
];
\addplot fill between[
of = f02 and f3,
soft clip={domain=25.9:40},
every even segment/.style  = {gray,opacity=.4}
];
\addplot fill between[
of = f4 and f5,
soft clip={domain=40:43},
every even segment/.style  = {gray,opacity=.4}
];
\draw[fill=black] (axis cs:0,5) circle (0.7mm);
\draw[fill=black] (axis cs:15,2) circle (0.7mm);
\draw[fill=black] (axis cs:40,0) circle (0.7mm);
\draw[fill=black] (axis cs:25.8,0.58) circle (0.7mm);
\node at (axis cs:25,3) {Feasible region};
%
%\node at (axis cs:0.7,-0.2) {$O$};
%\node[right] at (axis cs:0.1,5) {$(0,5)$};
%\node[above] at (axis cs:16,2.1) {$(15,2)$};
%\node[above] at (axis cs:180/7+2,4/7) {$(\frac{180}{7},\frac{4}{7})$};
%\node[above] at (axis cs:40,0) {$(40,0)$};
\end{axis}
\end{tikzpicture}
\end{document}

答案1

使用 \pgfplotsset 可以全局安装选项,即适用于所有轴环境。我认为您想在一个图中本地安装它们。

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{cancel}
\usepackage{pgfplots}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{amssymb}
\usepgfplotslibrary{fillbetween}
\newenvironment{tightcenter}{
\setlength\topsep{0pt}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
\definecolor{Elite}{RGB}{37,97,172}
First graph where I do not need ticks\\
\\
\pgfplotsset{every axis/.append style={
axis x line=middle,    % put the x axis in the middle
axis y line=middle,    % put the y axis in the middle
axis line style={<->}, % arrows on the axis
%ticks=none,
width=10.5cm,
height=8cm
}}
\begin{tikzpicture}
\begin{axis}[ticks=none,
xmin=-0.5,xmax=5.7,ymin=-0.1,ymax=0.35,
xlabel={$t$(\text{min})},
ylabel={$d$(\text{m})},
yticklabel style={
    fill=white,
    %yshift=10pt,
},
xticklabel style={
    %xshift=10pt,
    fill=white
}
]
\addplot[thick,color=black,samples=100,domain=0:1] {0.25*x};
\addplot[thick,color=black,samples=100,domain=1:2.25] {0.25};
\addplot[thick,color=black,samples=100,domain=2.25:4.25] {-0.125*x+0.53125};
%\addplot[ultra thick,color=black,samples=100,domain=0:-0.4,->] {0};
\node [below] at (axis cs: +0.15,0){$O$};
\node [below] at (axis cs: 1,0){$1$};
\node [below] at (axis cs: 2.25,0){$2.25$};
\node [below] at (axis cs: 4.25,0){$4.25$};
\node [left] at (axis cs: 0,0.25){$100$};
%\node [below] at (axis cs: 7/3,-0.01){$\frac{7}{3}$};
%\node [left] at (axis cs: 0,0.5){$a$};
\draw[fill=black] (axis cs:0,0) circle (0.7mm);
\draw[fill=black] (axis cs:7/3,0.5) circle (0.7mm);
%\draw[fill=white] (axis cs:7/3,0) circle (0.7mm);
\draw[thick,dashed](axis cs:1,0) -- (axis cs:1,0.25);
\draw[thick,dashed](axis cs:2.25,0) -- (axis cs:2.25,0.25);
\draw[thick,dashed](axis cs:0,0.25) -- (axis cs:1,0.25);
%
\draw[thick,Elite](axis cs:2.25,0.25) -- (axis cs:3.1,0);
\node [Elite,below] at (axis cs: 3.31,0){$3.31$};
\end{axis}
\end{tikzpicture}\\\\
\\\\
Next graph is missing ticks hmm\\
\\
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
grid=major,
xmin=-1,
xmax=43,
ymin=-0.3,
ymax=5.2,
xtick={0,5,10,15,20,25,30,35,40,45},
ytick={0,1,2,3,4,5},
height=9cm,
width=12cm,
axis line style={shorten >=-10pt, shorten <=-10pt},
ylabel style={
anchor=south,
at={(ticklabel* cs:1.0)},
yshift=10pt
},
ylabel=\textit{y},
xlabel style={
anchor=west,
at={(ticklabel* cs:1.0)},
xshift=10pt
},
xlabel=\textit{x}
]
\addplot[thick,samples=100,domain=0:25] {5-1/5*x};
\addplot[thick,samples=100,domain=0:30] {4-2/15*x};
\addplot[thick,samples=100,domain=0:40] {8/5-1/25*x};
%
\addplot[name path=f0,thick,opacity=0,samples=100,domain=0:15] {5.2};
\addplot[name path=f1,thick,opacity=0,samples=100,domain=0:15] {5-1/5*x};
\addplot[name path=f01,thick,opacity=0,samples=100,domain=15:25.9] {5.2};
\addplot[name path=f2,thick,opacity=0,samples=100,domain=15:25.9] {4-2/15*x};
\addplot[name path=f02,thick,opacity=0,samples=100,domain=25.9:43] {5.2};
\addplot[name path=f3,thick,opacity=0,samples=100,domain=25.9:40] {8/5-1/25*x};
\addplot[name path=f4,thick,opacity=0,samples=100,domain=0:43] {5.2};
\addplot[name path=f5,thick,opacity=0,samples=100,domain=0:43] {0};
%
\addplot fill between[
of = f0 and f1,
soft clip={domain=0:40},
every even segment/.style  = {gray,opacity=.4}
];
\addplot fill between[
of = f01 and f2,
soft clip={domain=15:25.9},
every even segment/.style  = {gray,opacity=.4}
];
\addplot fill between[
of = f02 and f3,
soft clip={domain=25.9:40},
every even segment/.style  = {gray,opacity=.4}
];
\addplot fill between[
of = f4 and f5,
soft clip={domain=40:43},
every even segment/.style  = {gray,opacity=.4}
];
\draw[fill=black] (axis cs:0,5) circle (0.7mm);
\draw[fill=black] (axis cs:15,2) circle (0.7mm);
\draw[fill=black] (axis cs:40,0) circle (0.7mm);
\draw[fill=black] (axis cs:25.8,0.58) circle (0.7mm);
\node at (axis cs:25,3) {Feasible region};
%
%\node at (axis cs:0.7,-0.2) {$O$};
%\node[right] at (axis cs:0.1,5) {$(0,5)$};
%\node[above] at (axis cs:16,2.1) {$(15,2)$};
%\node[above] at (axis cs:180/7+2,4/7) {$(\frac{180}{7},\frac{4}{7})$};
%\node[above] at (axis cs:40,0) {$(40,0)$};
\end{axis}
\end{tikzpicture}
\end{document}

相关内容