1


06/21/2020 I have two others question:

  1. In every graph i would add the "0" close the point (0;0). How can i fix it?

  2. In the last graph in the x axis the distance between 0 and 50 it's different between the distance from 50 to 100, 100 to 150 excetera...how can i fix it? i would like that those distance (showed by red and blu lines) should be equal.

Thanks for your help.

enter image description here


I have to do the following graphs. my problem is that the x axis y axis have different scales. how can i fix the graphs?

enter image description here

enter image description here

enter image description here

This is my code:

graph 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 uses numprint for number printing % this macro turns on explicit plus signs \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}

graph 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 Answer 1

3

I have not much experience with tkz-euclide and other packages that start with "tkz", nor do I know how one can get the fonts without some efforts, but I feel you will be much better off if you used 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}

enter image description here

5
  • thanks a lot! I would like to write the number 3000 like 3.000 instead 3,000; how can I fix it?
    – ryuk
    Jun 23, 2019 at 19:52
  • when I try to compile there's an error "! Package pgfkeys Error: Choice '1.16' unknown in choice key '/pgfplots/compat/ anchors'. I am going to ignore this key. See the pgfkeys package documentation for explanation. Type H <return> for immediate help.". How can I fix it? ...
    – ryuk
    Jun 23, 2019 at 19:54
  • 1
    @ryuk The error message means that you have an older TeX installation. If you do not want to upgrade, you can try \pgfplotsset{compat=newest,every axis/.append style={/pgf/number format/.cd,relative*={3}, use comma}}, where every axis/.append style={/pgf/number format/.cd,relative*={3}, use comma} addresses your first comment.
    – user121799
    Jun 23, 2019 at 20:00
  • how can i write "x [l]" under the x axis instead on the top of it?
    – ryuk
    Jun 23, 2019 at 22:38
  • 1
    @ryuk I need to run now, will be back in a few hours. (See p. 241 of the pgfplots manual v 1.16.)
    – user121799
    Jun 23, 2019 at 22:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .