Quero trocar duas cores de plotagem na minha figura. Por favor, dê uma olhada nisso:
Como você pode ver, o gráfico de “curto prazo” é omitido na segunda figura. Assim, para reduzir confusões ao estudar as duas figuras, quero mudar a cor do “curto prazo” da figura 1 para marrom e do “longo prazo” para vermelho. Este é o meu código:
\documentclass[12pt]{article}
\usepackage[left=3cm,top=3.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{filecontents}
\usepackage[margin=1cm]{caption}
\captionsetup[figure]{skip=18pt}
\begin{filecontents}{\jobname Data1.csv}
Price;OneSided;ShortRun;LongRun
5;8.7;4;20.3
10;16;11.7;20.7
15;22.2;18.2;21
20;27.6;23.9;21.3
30;36.3;33.1;21.7
40;43.2;40.3;22.1
50;48.8;46.2;22.4
60;53.3;50.9;22.6
70;57.1;54.9;22.8
80;60.4;58.3;23
90;63.1;61.3;23.1
100;65.6;63.8;23.3
\end{filecontents}
\begin{filecontents}{\jobname Data3.csv}
Price;OneSided;LongRun
5;8.7;14.9
10;16;17.5
15;22.2;20.1
20;27.6;22.7
30;36.3;28
40;43.2;33.2
50;48.8;38.4
60;53.3;43.7
70;57.1;48.9
80;60.4;54.1
90;63.1;59.3
100;65.6;64.6
\end{filecontents}
\begin{document}
\begin{figure}
\caption[Comparison of critical diversion ratios over different prices]
{Comparison of critical diversion ratios over different prices.}
\label{PlotSymmetrischDR}
\centering
\begin{tikzpicture}
\begin{axis}[style={auto},legend pos=north west,ymin=0,
% xtick={5,10,15,20,25,30,40,50,60,70,80,90,100},
x tick label style={/pgf/number format/1000 sep=},
xlabel={Price increase, in \%},
y tick label style={/pgf/number format/1000 sep=},
ylabel={Critical diversion ratio, in \%}
]
\addplot table [y=OneSided,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{One-sided}
\addplot table [y=ShortRun,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{Short-run}
\addplot table [y=LongRun,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{Long-run}
\end{axis}
\end{tikzpicture}
\end{figure}
\begin{figure}
\caption[Comparison of critical diversion ratios over different prices]
{Comparison of critical diversion ratios over different prices.}
\label{PlotASymmetrischDR}
\centering
\begin{tikzpicture}
\begin{axis}[style={auto},legend pos=north west,ymin=0,
% xtick={5,10,15,20,25,30,40,50,60,70,80,90,100},
x tick label style={/pgf/number format/1000 sep=},
xlabel={Price increase, in \%},
y tick label style={/pgf/number format/1000 sep=},
ylabel={Critical diversion ratio, in \%}
]
\addplot table [y=OneSided,col sep=semicolon] {\jobname Data3.csv};
\addlegendentry{One-sided}
\addplot table [y=LongRun,col sep=semicolon] {\jobname Data3.csv};
\addlegendentry{Long-run}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
Tentei inserir red
ou brown
no \addplot table [y=ShortRun,col sep=semicolon]
, como sugeridoaqui, mas isso não muda nada. Alguém pode me ajudar, por favor, descobrir o que estou fazendo de errado?
Além disso, é possível colocar esses números lado a lado? Tentei mudar o tamanho de toda a figura, para que cabessem uma ao lado da outra, mas não ficou muito bom. Talvez existam outras soluções que eu possa experimentar?
Obrigado pela ajuda!
Responder1
Solução 1: Basta trocar a ordem dos gráficos na primeira figura.
\documentclass[12pt]{article}
\usepackage[left=3cm,top=3.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{filecontents}
\usepackage[margin=1cm]{caption}
\captionsetup[figure]{skip=18pt}
\begin{filecontents}{\jobname Data1.csv}
Price;OneSided;ShortRun;LongRun
5;8.7;4;20.3
10;16;11.7;20.7
15;22.2;18.2;21
20;27.6;23.9;21.3
30;36.3;33.1;21.7
40;43.2;40.3;22.1
50;48.8;46.2;22.4
60;53.3;50.9;22.6
70;57.1;54.9;22.8
80;60.4;58.3;23
90;63.1;61.3;23.1
100;65.6;63.8;23.3
\end{filecontents}
\begin{filecontents}{\jobname Data3.csv}
Price;OneSided;LongRun
5;8.7;14.9
10;16;17.5
15;22.2;20.1
20;27.6;22.7
30;36.3;28
40;43.2;33.2
50;48.8;38.4
60;53.3;43.7
70;57.1;48.9
80;60.4;54.1
90;63.1;59.3
100;65.6;64.6
\end{filecontents}
\begin{document}
\begin{figure}
\caption[Comparison of critical diversion ratios over different prices]
{Comparison of critical diversion ratios over different prices.}
\label{PlotSymmetrischDR}
\centering
\begin{tikzpicture}
\begin{axis}[style={auto},legend pos=north west,ymin=0,
% xtick={5,10,15,20,25,30,40,50,60,70,80,90,100},
x tick label style={/pgf/number format/1000 sep=},
xlabel={Price increase, in \%},
y tick label style={/pgf/number format/1000 sep=},
ylabel={Critical diversion ratio, in \%}
]
\addplot table [y=OneSided,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{One-sided}
\addplot table [y=LongRun,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{Long-run}
\addplot table [y=ShortRun,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{Short-run}
\end{axis}
\end{tikzpicture}
\end{figure}
\begin{figure}
\caption[Comparison of critical diversion ratios over different prices]
{Comparison of critical diversion ratios over different prices.}
\label{PlotASymmetrischDR}
\centering
\begin{tikzpicture}
\begin{axis}[style={auto},legend pos=north west,ymin=0,
% xtick={5,10,15,20,25,30,40,50,60,70,80,90,100},
x tick label style={/pgf/number format/1000 sep=},
xlabel={Price increase, in \%},
y tick label style={/pgf/number format/1000 sep=},
ylabel={Critical diversion ratio, in \%}
]
\addplot table [y=OneSided,col sep=semicolon] {\jobname Data3.csv};
\addlegendentry{One-sided}
\addplot table [y=LongRun,col sep=semicolon] {\jobname Data3.csv};
\addlegendentry{Long-run}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
Solução 2: altere a cor do gráfico na Figura 2 manualmente:
\documentclass[12pt]{article}
\usepackage[left=3cm,top=3.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{filecontents}
\usepackage[margin=1cm]{caption}
\captionsetup[figure]{skip=18pt}
\begin{filecontents}{\jobname Data1.csv}
Price;OneSided;ShortRun;LongRun
5;8.7;4;20.3
10;16;11.7;20.7
15;22.2;18.2;21
20;27.6;23.9;21.3
30;36.3;33.1;21.7
40;43.2;40.3;22.1
50;48.8;46.2;22.4
60;53.3;50.9;22.6
70;57.1;54.9;22.8
80;60.4;58.3;23
90;63.1;61.3;23.1
100;65.6;63.8;23.3
\end{filecontents}
\begin{filecontents}{\jobname Data3.csv}
Price;OneSided;LongRun
5;8.7;14.9
10;16;17.5
15;22.2;20.1
20;27.6;22.7
30;36.3;28
40;43.2;33.2
50;48.8;38.4
60;53.3;43.7
70;57.1;48.9
80;60.4;54.1
90;63.1;59.3
100;65.6;64.6
\end{filecontents}
\begin{document}
\begin{figure}
\caption[Comparison of critical diversion ratios over different prices]
{Comparison of critical diversion ratios over different prices.}
\label{PlotSymmetrischDR}
\centering
\begin{tikzpicture}
\begin{axis}[style={auto},legend pos=north west,ymin=0,
% xtick={5,10,15,20,25,30,40,50,60,70,80,90,100},
x tick label style={/pgf/number format/1000 sep=},
xlabel={Price increase, in \%},
y tick label style={/pgf/number format/1000 sep=},
ylabel={Critical diversion ratio, in \%}
]
\addplot table [y=OneSided,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{One-sided}
\addplot table [y=ShortRun,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{Short-run}
\addplot table [y=LongRun,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{Long-run}
\end{axis}
\end{tikzpicture}
\end{figure}
\begin{figure}
\caption[Comparison of critical diversion ratios over different prices]
{Comparison of critical diversion ratios over different prices.}
\label{PlotASymmetrischDR}
\centering
\begin{tikzpicture}
\begin{axis}[style={auto},legend pos=north west,ymin=0,
% xtick={5,10,15,20,25,30,40,50,60,70,80,90,100},
x tick label style={/pgf/number format/1000 sep=},
xlabel={Price increase, in \%},
y tick label style={/pgf/number format/1000 sep=},
ylabel={Critical diversion ratio, in \%}
]
\addplot table [y=OneSided,col sep=semicolon] {\jobname Data3.csv};
\addlegendentry{One-sided}
\addplot+[brown,mark=*,every mark/.append style={solid, fill=brown}] table [y=LongRun,col sep=semicolon] {\jobname Data3.csv};
\addlegendentry{Long-run}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
Observe que a formatação vai em \addplot[]
, não em ... table []
, onde +
indica acréscimo.
Solução 3: Na Figura 2, pule um nalista de ciclo(a sequência de estilos aplicados a cada plotagem sucessiva). Isso pode ser feito da \pgfplotsset{cycle list shift=1}
seguinte maneira.
\documentclass[12pt]{article}
\usepackage[left=3cm,top=3.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{filecontents}
\usepackage[margin=1cm]{caption}
\captionsetup[figure]{skip=18pt}
\begin{filecontents}{\jobname Data1.csv}
Price;OneSided;ShortRun;LongRun
5;8.7;4;20.3
10;16;11.7;20.7
15;22.2;18.2;21
20;27.6;23.9;21.3
30;36.3;33.1;21.7
40;43.2;40.3;22.1
50;48.8;46.2;22.4
60;53.3;50.9;22.6
70;57.1;54.9;22.8
80;60.4;58.3;23
90;63.1;61.3;23.1
100;65.6;63.8;23.3
\end{filecontents}
\begin{filecontents}{\jobname Data3.csv}
Price;OneSided;LongRun
5;8.7;14.9
10;16;17.5
15;22.2;20.1
20;27.6;22.7
30;36.3;28
40;43.2;33.2
50;48.8;38.4
60;53.3;43.7
70;57.1;48.9
80;60.4;54.1
90;63.1;59.3
100;65.6;64.6
\end{filecontents}
\begin{document}
\begin{figure}
\caption[Comparison of critical diversion ratios over different prices]
{Comparison of critical diversion ratios over different prices.}
\label{PlotSymmetrischDR}
\centering
\begin{tikzpicture}
\begin{axis}[style={auto},legend pos=north west,ymin=0,
% xtick={5,10,15,20,25,30,40,50,60,70,80,90,100},
x tick label style={/pgf/number format/1000 sep=},
xlabel={Price increase, in \%},
y tick label style={/pgf/number format/1000 sep=},
ylabel={Critical diversion ratio, in \%}
]
\addplot table [y=OneSided,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{One-sided}
\addplot table [y=ShortRun,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{Short-run}
\addplot table [y=LongRun,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{Long-run}
\end{axis}
\end{tikzpicture}
\end{figure}
\begin{figure}
\caption[Comparison of critical diversion ratios over different prices]
{Comparison of critical diversion ratios over different prices.}
\label{PlotASymmetrischDR}
\centering
\begin{tikzpicture}
\begin{axis}[style={auto},legend pos=north west,ymin=0,
% xtick={5,10,15,20,25,30,40,50,60,70,80,90,100},
x tick label style={/pgf/number format/1000 sep=},
xlabel={Price increase, in \%},
y tick label style={/pgf/number format/1000 sep=},
ylabel={Critical diversion ratio, in \%}
]
\addplot table [y=OneSided,col sep=semicolon] {\jobname Data3.csv};
\addlegendentry{One-sided}
\pgfplotsset{cycle list shift=1}
\addplot table [y=LongRun,col sep=semicolon] {\jobname Data3.csv};
\addlegendentry{Long-run}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
Além disso, é possível colocar esses números lado a lado? Tentei mudar o tamanho de toda a figura, para que cabessem uma ao lado da outra, mas não ficou muito bom. Talvez existam outras soluções que eu possa experimentar?
Você já viu esta pergunta:Duas figuras lado a lado?
Da mesma forma, em termos de dimensionamento de seus gráficos,existem várias opções.
A solução a seguir usa minipáginas para figuras lado a lado e caixa de redimensionamento para dimensionar os gráficos de acordo:
\documentclass[12pt]{article}
\usepackage[left=3cm,top=3.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{filecontents}
\usepackage[margin=1cm]{caption}
\captionsetup[figure]{skip=18pt}
\begin{filecontents}{\jobname Data1.csv}
Price;OneSided;ShortRun;LongRun
5;8.7;4;20.3
10;16;11.7;20.7
15;22.2;18.2;21
20;27.6;23.9;21.3
30;36.3;33.1;21.7
40;43.2;40.3;22.1
50;48.8;46.2;22.4
60;53.3;50.9;22.6
70;57.1;54.9;22.8
80;60.4;58.3;23
90;63.1;61.3;23.1
100;65.6;63.8;23.3
\end{filecontents}
\begin{filecontents}{\jobname Data3.csv}
Price;OneSided;LongRun
5;8.7;14.9
10;16;17.5
15;22.2;20.1
20;27.6;22.7
30;36.3;28
40;43.2;33.2
50;48.8;38.4
60;53.3;43.7
70;57.1;48.9
80;60.4;54.1
90;63.1;59.3
100;65.6;64.6
\end{filecontents}
\begin{document}
\begin{figure}
\centering
\begin{minipage}{0.49\textwidth}
\caption[Comparison of critical diversion ratios over different prices]
{Comparison of critical diversion ratios over different prices.}
\label{PlotSymmetrischDR}
\centering
\resizebox{\textwidth}{!}{
\begin{tikzpicture}
\begin{axis}[style={auto},legend pos=north west,ymin=0,
% xtick={5,10,15,20,25,30,40,50,60,70,80,90,100},
x tick label style={/pgf/number format/1000 sep=},
xlabel={Price increase, in \%},
y tick label style={/pgf/number format/1000 sep=},
ylabel={Critical diversion ratio, in \%}
]
\addplot table [y=OneSided,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{One-sided}
\addplot table [y=ShortRun,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{Short-run}
\addplot table [y=LongRun,col sep=semicolon] {\jobname Data1.csv};
\addlegendentry{Long-run}
\end{axis}
\end{tikzpicture}
}
\end{minipage}
\hfill
\begin{minipage}{0.49\textwidth}
\caption[Comparison of critical diversion ratios over different prices]
{Comparison of critical diversion ratios over different prices.}
\label{PlotASymmetrischDR}
\centering
\resizebox{\textwidth}{!}{
\begin{tikzpicture}
\begin{axis}[style={auto},legend pos=north west,ymin=0,
% xtick={5,10,15,20,25,30,40,50,60,70,80,90,100},
x tick label style={/pgf/number format/1000 sep=},
xlabel={Price increase, in \%},
y tick label style={/pgf/number format/1000 sep=},
ylabel={Critical diversion ratio, in \%}
]
\addplot table [y=OneSided,col sep=semicolon] {\jobname Data3.csv};
\addlegendentry{One-sided}
\addplot+[brown,mark=*,every mark/.append style={solid, fill=brown}] table [y=LongRun,col sep=semicolon] {\jobname Data3.csv};
\addlegendentry{Long-run}
\end{axis}
\end{tikzpicture}
}
\end{minipage}
\end{figure}
\end{document}