Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
58 lines (52 sloc)
1.3 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{graphicx} | |
\usepackage{pgfplots} | |
\usetikzlibrary{math} | |
\begin{document} | |
\begin{figure}[htbp] | |
\centering | |
\resizebox{\textwidth}{!}{% | |
\begin{tikzpicture} | |
\tikzmath{ | |
\r1 = 4; | |
\r2 = 3; | |
\r3 = 2; | |
\q1 = 5; | |
\q2 = 10; | |
\q3 = 20; | |
\x1 = \q1; \y1 = \r1*\q1; | |
\x2 = \q2; \y2 =\r2 * \q2; | |
\x3 = \q3; \y3 = \r3 * \q3; | |
} | |
\begin{axis}[ | |
axis x line=middle, | |
axis y line=middle, | |
ylabel=Total Price, | |
xlabel=Quantity, | |
xtick={0,\x1,\x2,\x3}, | |
xticklabels={0,$q_1$, $q_2$, $q_3$,{ }}, | |
xlabel near ticks, | |
ytick={0, \y1, \y2, \y3}, | |
yticklabels={0,$p_1$, $p_2$, $p_3$}, | |
ylabel near ticks, | |
xmax=\x3+5, | |
ymax=\y3+5, | |
xmin=0, | |
ymin=0 | |
] | |
\addplot[domain=0:\q1] {\r1*x}; | |
\addplot[domain=\q1:\q2] {\r2*x}; | |
\addplot[domain=\q2:\q3] {\r3*x}; | |
\draw[dotted] (axis cs:\x1,\y1) -- (axis cs:\x1, 0); | |
\draw[dotted] (axis cs:\x2,\y2) -- (axis cs:\x2, 0); | |
\draw[dotted] (axis cs:\x3,\y3) -- (axis cs:\x3, 0); | |
\draw[dotted] (axis cs:\x1,\y1) -- (axis cs:0, \y1); | |
\draw[dotted] (axis cs:\x2,\y2) -- (axis cs:0, \y2); | |
\draw[dotted] (axis cs:\x3,\y3) -- (axis cs:0, \y3); | |
\addplot[fill=white,only marks,mark=*] coordinates{(0,0)(\q1,\r2*\q1)(\q2,\r3*\q2)}; | |
\addplot[only marks,mark=*] coordinates{(\x1,\y1)(\x2,\y2)(\x3,\y3)}; | |
\end{axis} | |
\end{tikzpicture} | |
}% | |
\end{figure} | |
\end{document} |