当在线之间添加填充时,导致缩放停止工作,我的节点很容易修复,但现在标题与图形之间的距离很奇怪。
\documentclass[a4paper,11pt]{article}
\usepackage{graphicx} % Required for inserting images
%\usepackage[margin=0.55in]{geometry}
\usepackage{pgfplots}
\usepackage{biblatex}
\usepackage{tikz,pgfplots}
\usepackage{url}
\usepackage{hyperref}
\addbibresource{references.bib}
\AtBeginBibliography{\small} %ta bort om inte behöver platsen
\pgfplotsset{width=10cm,compat=1.9}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
% We will externalize the figures
\usepgfplotslibrary{external}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\tikzexternalize
\begin{document}
\begin{figure}[h!]
\centering
\begin{tikzpicture}[scale=0.7]
\begin{axis}[axis lines=center,
xlabel={$q$},
ylabel={$p$},
xlabel style={below right},
ylabel style={above right},
ymin=0,
xmin=0,
xmax=1.05,
ymax=1.05,
yticklabels={,,},
xticklabels={,,}]
\addplot[name path=D,color=red, domain = 0:1]{-3*x+1.5}
node [color=black, pos=0.2, above right,scale=0.7] {Efterfrågan};
\addplot[name path=SuS,color=blue, samples = 100, domain = 0:1]{4*(x-0.1)^2+0.15}
node [ color=black, pos=0.3,below right,scale=0.7] {Skattfritt utbud};
\addplot[name path =SS,color=magenta, samples = 100, domain = 0:1]{((4*(x-0.1)^2+0.15)+0.03)*1.4}
node [color=black, pos=0.07,above left,align=center,scale=0.7] {Utbud\\med skatt};
\addplot[color=blue,fill opacity=0.3] fill between[of=SuS and SS];
\end{axis}
\end{tikzpicture}
\caption{Utbuds påverkan av skatt}
\label{fig:Skatt}
\end{figure}
\end{document}
答案1
我通过将缩放移到轴条件中来解决这个问题
\documentclass[a4paper,11pt]{article}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{tikz,pgfplots}
\pgfplotsset{width=10cm,compat=1.9}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\usepgfplotslibrary{external}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\tikzexternalize
\begin{document}
\begin{figure}[h!]
\centering
\begin{tikzpicture}[scale=0.7]
\begin{axis}[axis lines=center,
xlabel={$q$},
ylabel={$p$},
xlabel style={below right},
ylabel style={above right},
ymin=0,
xmin=0,
xmax=1.05,
ymax=1.05,
yticklabels={,,},
xticklabels={,,}]
\addplot[name path=D,color=red, domain = 0:1]{-3*x+1.5}
node [color=black, pos=0.2, above right,scale=0.7] {Efterfrågan};
\addplot[name path=SuS,color=blue, samples = 100, domain = 0:1]{4*(x-0.1)^2+0.15}
node [ color=black, pos=0.3,below right,scale=0.7] {Skattfritt utbud};
\addplot[name path =SS,color=magenta, samples = 100, domain = 0:1]{((4*(x-0.1)^2+0.15)+0.03)*1.4}
node [color=black, pos=0.07,above left,align=center,scale=0.7] {Utbud\\med skatt};
\addplot[color=blue,fill opacity=0.3] fill between[of=SuS and SS];
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}