具有不同比例(x 和 y)的图形问题

具有不同比例(x 和 y)的图形问题


2020 年 6 月 21 日我还有两个问题:

  1. 在每个图表中,我都会在点 (0;0) 附近添加“0”。我该如何修复它?

  2. 在最后一张图中,x 轴上 0 到 50 之间的距离与 50 到 100、100 到 150 之间的距离不同……我该如何修复它?我希望这些距离(红线和蓝线表示)应该相等。

感谢您的帮助。

在此处输入图片描述


我必须制作以下图表。我的问题是 x 轴和 y 轴有不同的比例。我该如何修复图表?

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

这是我的代码:

图1:

\documentclass[border=5mm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage[utf8x]{inputenc}
\usepackage{libertine}

\begin{document} \begin{tikzpicture}[every label/.append style={font=\Large}] % \tkzAxeXY 使用 numprint 进行数字打印 % 此宏打开显式加号 \npaddplus

\tkzInit[xmin=0,ymin=0,xmax=6,ymax=5]
\tkzGrid % moved before \tkzAxeXY
\tkzAxeX[
   label=\hspace{4mm}{\Large $ \qquad x \left[\text{l} \right] $},
   very thick, % increase width of axes lines
   label options={font=\large}, % increase font size 
   orig=false % don't print zeros
]
\tkzAxeY[
   label=\raisebox{4mm}{\Large $P(x) \left[ \textsc{\$} \right]$},
   very thick, % increase width of axes lines
   label options={font=\large,}, % increase font size 
   orig=false % don't print zeros
]
% add zero label manually
   \node [below left=3pt,fill=white,font=\large] {$0$};

\end{tikzpicture}
\end{document}

图2:

\documentclass[border=5mm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage[utf8x]{inputenc}
\usepackage{libertine}



\begin{document}
\begin{tikzpicture}[every label/.append style={font=\Large}]
% \tkzAxeXY uses numprint for number printing
% this macro turns on explicit plus signs
\npaddplus

\tkzInit[xmin=0,ymin=-3,xmax=8,ymax=7]
\tkzGrid % moved before \tkzAxeXY
\tkzAxeX[
   label=\hspace{4mm}{\Large $ \qquad x \left[\text{l} \right] $},
   very thick, % increase width of axes lines
   label options={font=\large}, % increase font size 
   orig=false % don't print zeros
]
\tkzAxeY[
   label=\raisebox{4mm}{\Large $R(x)  \, , C(x) \\ \left[ \textsc{\$} \right]$ \\  },
   very thick, % increase width of axes lines
   label options={font=\large,}, % increase font size 
   orig=false % don't print zeros
]
% add zero label manually
   \node [below left=3pt,fill=white,font=\large] {$0$};

\end{tikzpicture}
\end{document}

答案1

我对 tkz-euclide 和其他以“tkz”开头的软件包没有太多经验,也不知道如何不费吹灰之力就能获得字体,但我觉得如果你使用 ,效果会更好pgfplots

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{amsmath,amssymb}
\usepackage{pgfplots}
\pgfplotsset{compat=newest,
every axis/.append style={axis on top,grid=major,axis lines=middle,
    every axis x label/.style={
            at={([yshift=1em]xticklabel cs:1)},
            anchor=south west,
        },
    every axis y label/.style={
            at={(axis description cs:0,1)},anchor=south west,
        },
    /pgf/number format/.cd,relative*={3}, use comma}}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
 \begin{axis}[ymax=5000,
 ytick={000,1000,...,5000},xtick={0,10,...,60},
 xlabel={$x\left[\text{l} \right]$},ylabel={$y\left[\$ \right]$}]
  \addplot[domain=0:60,name path=steeper] {x*400/6} coordinate[pos=5/6] (p1);
  \addplot[domain=0:60,name path=less steep] {1000+x*200/6} coordinate[pos=5/6] (p2);
  \path[fill=green!40!white,
   intersection segments={of=steeper and less steep,sequence={A1 -- B1[reverse]}}];
  \path[fill=red!40!white,
   intersection segments={of=steeper and less steep,sequence={A0 -- B0[reverse]}}];
  \draw[blue] (p1) to[bend left=5] ++ (-0.1cm,0.3cm)  node[above,black]{$\boldsymbol{R(x)}$};
  \draw[blue] (p2) to[bend left=5] ++ (0,-0.3cm)  node[below,black]{$\boldsymbol{C(x)}$};
  \path[name intersections={of=steeper and less steep}]
   (intersection-1) node[circle,fill,inner sep=1.5pt,label=above:\textbf{BP}]{};
 \end{axis}
\end{tikzpicture}

\begin{tikzpicture}
 \begin{axis}[ymin=-3000,ymax=7000,
 ytick={-3000,-2000,...,7000},xtick={0,50,...,400},
 xlabel={$x\left[\text{l} \right]$},ylabel={$y\left[\$ \right]$}]
  \addplot[domain=0:400,name path=flat] {0} coordinate[pos=5/6] (p1);
  \addplot[domain=0:400,name path=raise] {-2000+x*20} coordinate[pos=5/6] (p2);
  \path[fill=green!40!white,
   intersection segments={of=flat and raise,sequence={A1 -- B1[reverse]}}];
  \path[fill=red!40!white,
   intersection segments={of=flat and raise,sequence={A0 -- B0[reverse]}}];
  \path[name intersections={of=flat and raise}]
   (intersection-1) node[circle,fill,inner sep=1.5pt,label=above:\textbf{BP}]{};
 \end{axis}
\end{tikzpicture}

\begin{tikzpicture}
 \begin{axis}[ymin=-3000,ymax=7000,xmax=400,
 ytick={-3000,-2000,...,7000},xtick={0,50,...,400},
 xlabel={$x\left[\text{l} \right]$},ylabel={$y\left[\$ \right]$}]
  \addplot[domain=0:200,name path=curve] {5000-0.5*pow(x-150,2)};
  \addplot[dashed,domain=200:260,name path=dashed] {5000-0.5*pow(x-150,2)};
  \path[name path=flat] (0,0) -- (200,0);
  \path[fill=green!40!white,
   intersection segments={of=flat and curve,sequence={A1 -- B1[reverse]}}];
  \path[fill=red!40!white,
   intersection segments={of=flat and curve,sequence={A0 -- B0[reverse]}}];
  \path[name intersections={of=flat and curve}]
   (intersection-1) node[circle,fill,inner sep=1.5pt,label=above:\textbf{BP}]{};
 \end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容