我如何重新定义下面 MWE 中的小于不等式,以使其类似于屏幕截图所示的不等式?
这是使用的代码。
\begin{tikzpicture}[scale=0.7]
% Draw the grid
\tikzset{help lines/.style={color=blue!50}}
\draw[thick,step=1cm,help lines] (0,0) grid (20,13);
\draw[thin,step=2mm,help lines] (0,0) grid (20,13);
\begin{axis}[thick,
axis x line=center, axis y line=center,
axis on top,
width=16cm, height=16cm,
x axis line style={latex-latex},
y axis line style={latex-latex},
x=1cm,
y=1cm,
xtick={0,1,2,...,18},
ytick={0,1,2,...,12},
ticklabel style={font={{\normalsize }}, fill=white,
inner sep=1pt},
xmin=-2, xmax=18.5,
ymin=-1, ymax=12.5
]
%line one
\addplot [IneqStyleGtr,
domain=-1:18,line width=1.5pt,
] {-4*x+24};
%line two
\addplot [IneqStyleGtr,line width=1.5pt,
domain=-1:15,
] {-1.3333333333*x+10.666666666667};
%line three - y axis
\addplot [IneqStyleLess,
thick,black!80!white,domain=-1:18,line width=1.5pt] coordinates {(0,0) (18,0)};
\addplot [IneqStyleGtr,
thick,black!80!white,domain=-1:18,line width=1.5pt] coordinates {(0,0) (0,12)};
%line 4 x axis
\addplot [IneqStyleGtr,
thick,black!80!white,domain=-1:16,line width=1.5pt] {-0.5*x+9};
\node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:18,0.2) {$x$-axis};
\node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:0.6,12) {$y$};
%line one
\node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:11,0.2) {$y=0$};
\node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:4.2,11.3) {$4x+y=24$};
%line two
\node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:13.5,3) {$x+2y=18$};
%line three
\node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:8.5,1) {$4x+3y=32$};
%line four
\node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:-1,6) {$x=0$};
%ORIGIN
\node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:-0.2,-0.2) {$0$};
\end{axis}
\end{tikzpicture}
答案1
- 请始终提供 MWE(最小工作示例),这是一个完整的小型可编译文档,它可以重现您的问题并显示您在解决问题时遇到的问题。
- 你的问题不太清楚,你的问题是什么?你的代码片段包含未定义的命令,也与显示的图像不接近,所以我猜你在做什么。
- 像这样吗?
\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{intersections,
patterns}
\begin{document}
\begin{tikzpicture}[scale=0.5,
lbl/.style = {#1, near end, font=\small, sloped} % #1: position
]
\begin{axis}[
axis lines=center, semithick,
x=10mm, y=10mm,
xlabel=$x$,
ylabel=$y$,
label style = {font=\Large},
grid=both, minor tick num=9,
major grid style = {blue!30},
minor grid style = {very thin, blue!15},
ticklabel style={rounded corners, font=\scriptsize, fill=white, inner sep=1pt},
xmin=-10, xmax=10, xtick={-10,-9,...,10},
ymin=-10, ymax=10, ytick={-10,-9,...,10},
%
every axis plot post/.append style={thick, color=black},
domain = -10:10, no marks
]
%line one
\addplot[name path=A] {x} node[lbl=above] {$y>x$}
node[lbl=below] {$y<x$};
\path [name path=B] (-10,10) -- (-10,10);
\addplot[pattern=north west lines,
distance=2.82mm,
pattern color=orange!50]
fill between[of=A and B];
\end{axis}
\end{tikzpicture}
\end{document}