Graphics, Figures & TablesTweaking some parts of a chart

Information and discussion about graphics, figures & tables in LaTeX documents.
dasag
Posts: 30
Joined: Wed Dec 10, 2014 3:43 pm

Tweaking some parts of a chart

Post by dasag »

I created a graph in writeLaTeX, but I have some questions: How can set my Y-axis show only entering values (for example 1E+01), I don't want numbers?

Code: Select all

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}

\begin{tikzpicture}
% f1
\begin{axis}[
color=black,
scale only axis,
xmin=0,
xmax=24,
%xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24},
xtick={0,4,8,12,24}, %%%<------------- here
xlabel=\ {Time},
ymin=0,
ymax=10,
ytick={0,1,2,3,4,5,6,7,8,9,10},
yticklabels={0,1,2,3,4,5,6,7,8,9,10},
ylabel=\ {log(Cfu/cm$^{2}$)},
y axis line style={black},
ytick style={black},
yticklabel style={black},
axis x line*=bottom,
axis y line*=left, 
tick align = outside,]
\addplot [
color=black,
solid,
line width=0.5pt,
mark size=2.5pt,
mark size=2.5pt,
mark=square*,
mark options={solid,,rotate=180,fill=white}]
table[row sep=crcr]{
0 5\\
4 5\\
8 9.8\\
12 6.8\\
24 6.162\\};
\addplot [
color=black,
solid,
line width=0.5pt,
mark size=2.5pt,
mark size=2.5pt,
mark=square*,
mark options={solid,,rotate=180,fill=white}]
table[row sep=crcr]{
0 2\\
4 3\\
8 4.8\\
12 7.8\\
24 8.162\\};
\end{axis}
% f2
\begin{axis}[
color=black,
scale only axis,
xmin=0,
xmax=24,
ymin=0,
ymax=6,
ytick={0,1,2,3,4,5,6},
yticklabels={0,1,2,3,4,5,6},
axis x line*=none,
axis y line*=right,
ylabel=\ {RE},
ylabel style=black,
hide x axis,
tick align =outside,]
\addplot [
color=black,
solid,
line width=0.5pt,
mark size=2.5pt,
mark=*,
mark options={solid,fill=white}]
table[row sep=crcr]{
0 4.3\\
4 3.8\\
8 5.1\\
12 5.123\\
24 3.85\\};
\end{axis}
% f3
\begin{axis}[
color=black,
scale only axis,
xmin=0,
xmax=24,
ymin=0,
ymax=4000,
ytick={0,1,2000,4000},
yticklabels={0,1,2000,4000},
axis x line*=none,
axis y line*=right,
ylabel=\ {Enterotoxin production},
ylabel style=black,
hide x axis,
tick align =outside,]
\pgfplotsset{every outer y axis line/.style={xshift=1.5cm}, every tick/.style={xshift=1.5cm}, every y tick label/.style={xshift=1.5cm} }
\addplot [
color=black,
solid,
line width=0.5pt,
mark size=2.5pt,
mark=triangle*,
mark options={solid,,fill=white}]
table[row sep=crcr]{
0 2300\\
4 3800\\
8 3200\\
12 3123\\
24 2385\\};
\end{axis}
\end{tikzpicture}%
\end{document}
OtKRX.jpg
OtKRX.jpg (10.7 KiB) Viewed 6310 times
Also: How I can set my third Y axis show only numbers 2000 and 4000 Same as picture. I want code for latex

Thank you

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Tweaking some parts of a chart

Post by Johannes_B »

This questions has also been asked on TeX.SX.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

Tweaking some parts of a chart

Post by Stefan Kottwitz »

Specify ticks and ticklabels.

Code: Select all

ytick={2,5,7},
yticklabels={Value 1, Value 2, Value 3},
Add axis y discontinuity=parallel for the third axis. Values 2000 and 4000 are already there.

So you would get:
plot.png
plot.png (24.39 KiB) Viewed 6279 times
You could also explain more in detail, what you would like to achieve, perhaps it's not completely clear to us.

Stefan
LaTeX.org admin
dasag
Posts: 30
Joined: Wed Dec 10, 2014 3:43 pm

Re: Tweaking some parts of a chart

Post by dasag »

Thank you
Last edited by dasag on Fri Dec 12, 2014 8:45 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

Tweaking some parts of a chart

Post by Stefan Kottwitz »

I added it just here:

Code: Select all

ytick={0,1,2000,4000},% your code
yticklabels={0,1,2000,4000},% your code
axis y discontinuity=parallel,% new
...
in the third axis.

I just don't understand what you mean by 1E+03 10^x. You can add anything you want. Just add ytick with certain values matching the axis, and yticklabels for arbitrary labels.

Stefan
LaTeX.org admin
dasag
Posts: 30
Joined: Wed Dec 10, 2014 3:43 pm

Re: Tweaking some parts of a chart

Post by dasag »

Thank you very much dear Stephan,
Last edited by dasag on Fri Dec 12, 2014 8:45 pm, edited 1 time in total.
dasag
Posts: 30
Joined: Wed Dec 10, 2014 3:43 pm

Re: Tweaking some parts of a chart

Post by dasag »

Thank you
Last edited by dasag on Fri Dec 12, 2014 8:46 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

Tweaking some parts of a chart

Post by Stefan Kottwitz »

This code in the document preamble would rotate the discontinuity markers and shorten them a bit.

Code: Select all

\usepackage{etoolbox}
\makeatletter
\patchcmd{\pgfplots@drawaxis@lines@preparediscont@for}{ticks,segment length=4pt, amplitude=8pt}%
  {ticks,segment length=4pt, amplitude=5pt,transform={rotate=45}}{}{}
\makeatother
Stefan
LaTeX.org admin
dasag
Posts: 30
Joined: Wed Dec 10, 2014 3:43 pm

Re: Tweaking some parts of a chart

Post by dasag »

Thanks
Last edited by dasag on Fri Dec 12, 2014 8:43 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

Tweaking some parts of a chart

Post by Stefan Kottwitz »

This code patches a pgfplots command. So it has to be inserted after pgfplots has been loaded, i.e. below:

Code: Select all

\usepackage{pgfplots}
\pgfplotsset{compat=newest}
% now her it comes:
\usepackage{etoolbox}
\makeatletter
\patchcmd{\pgfplots@drawaxis@lines@preparediscont@for}{ticks,segment length=4pt, amplitude=8pt}%
  {ticks,segment length=4pt, amplitude=5pt,transform={rotate=45}}{}{}
\makeatother
You placed it before, so it did not have an effect on pgfplots. Sorry I did not mention this caveat.

Stefan
LaTeX.org admin
Post Reply