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

Re: Tweaking some parts of a chart

Post by dasag »

Thank you veryyyyyyyyyyyyyy much dear Stefan.
You look my question which send about X axis and 8 graph in one page

Best regards

Recommended reading 2024:

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

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

dasag
Posts: 30
Joined: Wed Dec 10, 2014 3:43 pm

Re: Tweaking some parts of a chart

Post by dasag »

Dear Stefan you received my mail?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Re: Tweaking some parts of a chart

Post by Stefan Kottwitz »

I got one some days ago I see. I seldom look into that mailbox, as I don't really use it but it's connected to some websites.

I just don't provide LaTeX support via email, as it costs much time and nobody pays it. Here in a public forum I post answers because public solutions may help further people and it extends the knowhow base of this Internet forum. I maintain this platform, so I feel responsible.

Even here, I'm not often these days: busy with work and family, and writing another LaTeX book, which means just sporadic posts by me. The chance to get something done is if a question is clear, focused, detailed, complete - answerable in one go. Unlike here. ;-) But feel free to open new topics.

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 »

Dear Stefan I say my last post about X axis and 8 graph in one page
Dear Stefan I send you hand-draw x-axis.
Attachments
Untitled-1.jpg
Untitled-1.jpg (164.33 KiB) Viewed 4218 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Re: Tweaking some parts of a chart

Post by Stefan Kottwitz »

I simply don't know what "I need my X axis show -168 hours, but when I write 0,4,8,12 hours very similar, how do all number far between." means.

The drawing showed me not much difference from what is already in the chart.

You go for a Ph.D.? Great. Take it as a challenge on the way to fine-tune a questions details and English wording for best legibility and readers will post a solution for anything. Should be easy for a Ph.D. candidate, and so you may get results. ;)

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

Tweaking some parts of a chart

Post by dasag »

That is very good answer, dear Stefan
Wen I do this operaion by latex code my X axis show very bad

You can see here

Code: Select all

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\definecolor{mycolor1}{rgb}{1,0,1}
\definecolor{mycolor2}{rgb}{0,0.498039215803146,0}

\begin{tikzpicture}
% f1
\begin{axis}[
color=black,
scale only axis,
xmin=0,
xmax=168,
%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,48,72,168},
xtick={0,4,8,12,24,48,72,168},   %%%<------------- 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={yellow},
yticklabel style={red},
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=blue}]
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=blue}]
table[row sep=crcr]{
0 2\\
4 3\\
8 4.8\\
12 7.8\\
24 8.162\\};
\end{axis}
% f2
\begin{axis}[
color=mycolor2,
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=mycolor2,
solid,
line width=1.5pt,
mark size=2.5pt,
mark=*,
mark options={solid,fill=mycolor2}]
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,2000,4000},
yticklabels={0,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=orange,
solid,
line width=1.5pt,
mark size=2.5pt,
mark=0,
mark options={solid,fill=mycolor2}]
table[row sep=crcr]{
0 1.3\\
4 0.8\\
8 2.1\\
12 2.123\\
24 2.85\\};
\end{axis}
\end{tikzpicture}%
\end{document}
dasag
Posts: 30
Joined: Wed Dec 10, 2014 3:43 pm

Re: Tweaking some parts of a chart

Post by dasag »

X-axis time 0,4,8,12 near-close to each other

Also You dont answer how do that 8 charts in one page, which code I need to write?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Tweaking some parts of a chart

Post by Stefan Kottwitz »

dasag wrote:X-axis time 0,4,8,12 near-close to each other
Those are the positions, they cannot be changed if chart and font remain the same. So change the scaling of the whole axis if they are too close to each other.
dasag wrote:Also You dont answer how do that 8 charts in one page, which code I need to write?
No matter if charts, numbers, images, ... could be minipages, parboxes, tabular... the latter seams the easiest. Look, the chart from here is just in a macro - repeated, just insert any chart you want:

Code: Select all

\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\newcommand*{\sample}{%
  \begin{tikzpicture}
	\begin{polaraxis}
	\addplot+[mark=none,domain=0:720,samples=600] 
		{sin(2*x)*cos(2*x)}; 
	\end{polaraxis}
  \end{tikzpicture}}
\begin{document}
\begin{tabular}{cccc}
  \sample & \sample & \sample & \sample \\
  \sample & \sample & \sample & \sample
\end{tabular}
\end{document}
Stefan
LaTeX.org admin
dasag
Posts: 30
Joined: Wed Dec 10, 2014 3:43 pm

Tweaking some parts of a chart

Post by dasag »

I have eight different graph. I read your comment and code. But I dont understand concrettly where I can write this codes. I send code of my eight grahph. Dear Stefan you can to create all 8 graph in one page. This is my end question. Thank you for all:

Code: Select all

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\definecolor{mycolor1}{rgb}{1,0,1}
\definecolor{mycolor2}{rgb}{0,0.498039215803146,0}

\begin{tikzpicture}
\begin{axis}[
color=black,
scale only axis,
xmin=1,
xmax=24,
%xtick={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={$y$},
ymin=1,
ymax=10,
ytick={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0},
yticklabels={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0},
y axis line style={blue},
ytick style={blue},
yticklabel style={blue},
axis x line*=bottom,
axis y line*=left,    
tick align = outside,]
\addplot [
color=blue,
solid,
line width=0.5pt,
mark size=2.5pt,
mark size=2.5pt,
mark=square*,
mark options={solid,,rotate=180,fill=blue}]
table[row sep=crcr]{
1 5\\
4 5\\
8 9.8\\
12 6.8\\
24 6.162\\};
\end{axis}
\end{tikzpicture}%
\end{document}

Code: Select all

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\definecolor{mycolor1}{rgb}{1,0,1}
\definecolor{mycolor2}{rgb}{0,0.498039215803146,0}

\begin{tikzpicture}
\begin{axis}[
color=black,
scale only axis,
xmin=1,
xmax=24,
%xtick={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={$y$},
ymin=1,
ymax=10,
ytick={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0},
yticklabels={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0},
y axis line style={black},
ytick style={yellow},
yticklabel style={red},
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=blue}]
table[row sep=crcr]{
1 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=blue}]
table[row sep=crcr]{
1 2\\
4 3\\
8 4.8\\
12 7.8\\
24 8.162\\};
\end{axis}
\end{tikzpicture}%
\end{document}

Code: Select all

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\definecolor{mycolor1}{rgb}{1,0,1}
\definecolor{mycolor2}{rgb}{0,0.498039215803146,0}

\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={$y$},
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={$sik$},
y axis line style={black},
ytick style={yellow},
yticklabel style={red},
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=blue}]
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=blue}]
table[row sep=crcr]{
0 2\\
4 3\\
8 4.8\\
12 7.8\\
24 8.162\\};
\end{axis}
% f2
\begin{axis}[
color=mycolor2,
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={$dasag$},
ylabel style=black,
hide x axis,
tick align =outside,]
\addplot [
color=mycolor2,
solid,
line width=1.5pt,
mark size=2.5pt,
mark=*,
mark options={solid,fill=mycolor2}]
table[row sep=crcr]{
0 4.3\\
4 3.8\\
8 5.1\\
12 5.123\\
24 3.85\\};
\end{axis}
\end{tikzpicture}%
\end{document}

Code: Select all

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\definecolor{mycolor1}{rgb}{1,0,1}
\definecolor{mycolor2}{rgb}{0,0.498039215803146,0}

\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={$sik$},
y axis line style={black},
ytick style={yellow},
yticklabel style={red},
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=blue}]
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=blue}]
table[row sep=crcr]{
0 2\\
4 3\\
8 4.8\\
12 7.8\\
24 8.162\\};
\end{axis}
% f2
\begin{axis}[
color=mycolor2,
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={$dasag$},
ylabel style=black,
hide x axis,
tick align =outside,]
\addplot [
color=mycolor2,
solid,
line width=1.5pt,
mark size=2.5pt,
mark=*,
mark options={solid,fill=mycolor2}]
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=6,
ytick={0,1,2,3,4,5,6},
yticklabels={0,1,2,3,4,5,6,7,8},
axis x line*=none,
axis y line*=right,
ylabel={$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=orange,
solid,
line width=1.5pt,
mark size=2.5pt,
mark=0,
mark options={solid,fill=mycolor2}]
table[row sep=crcr]{
0 1.3\\
4 0.8\\
8 2.1\\
12 2.123\\
24 2.85\\};
\end{axis}
\end{tikzpicture}%
\end{document}

Code: Select all

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\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
\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},% your code
yticklabels={0,1,2,3,4,5,6,7,8,9,10},% your code
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,2000,4000},% your code
yticklabels={0E+0,2E+03,4E+03},% your code
axis y discontinuity=parallel,% new
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}

Code: Select all

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\definecolor{mycolor1}{rgb}{1,0,1}
\definecolor{mycolor2}{rgb}{0,0.498039215803146,0}

\begin{tikzpicture}
\begin{axis}[
color=black,
scale only axis,
xmin=1,
xmax=24,
%xtick={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={$y$},
ymin=1,
ymax=10,
ytick={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0},
yticklabels={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0},
y axis line style={blue},
ytick style={blue},
yticklabel style={blue},
axis x line*=bottom,
axis y line*=left,    
tick align = outside,]
\addplot [
color=blue,
solid,
line width=0.5pt,
mark size=2.5pt,
mark size=2.5pt,
mark=square*,
mark options={solid,,rotate=180,fill=blue}]
table[row sep=crcr]{
1 1\\
4 2\\
8 2.8\\
12 3.8\\
24 1.162\\};
\end{axis}
\end{tikzpicture}%
\end{document}

Code: Select all

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\definecolor{mycolor1}{rgb}{1,0,1}
\definecolor{mycolor2}{rgb}{0,0.498039215803146,0}

\begin{tikzpicture}
\begin{axis}[
color=black,
scale only axis,
xmin=1,
xmax=24,
%xtick={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={$y$},
ymin=1,
ymax=10,
ytick={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0},
yticklabels={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0},
y axis line style={blue},
ytick style={blue},
yticklabel style={blue},
axis x line*=bottom,
axis y line*=left,    
tick align = outside,]
\addplot [
color=blue,
solid,
line width=0.5pt,
mark size=2.5pt,
mark size=2.5pt,
mark=square*,
mark options={solid,,rotate=180,fill=blue}]
table[row sep=crcr]{
1 1\\
4 2\\
8 2.8\\
12 4.8\\
24 8.162\\};
\end{axis}
\end{tikzpicture}%
\end{document}

Code: Select all

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\definecolor{mycolor1}{rgb}{1,0,1}
\definecolor{mycolor2}{rgb}{0,0.498039215803146,0}

\begin{tikzpicture}
\begin{axis}[
color=black,
scale only axis,
xmin=1,
xmax=24,
%xtick={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={$y$},
ymin=1,
ymax=10,
ytick={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0},
yticklabels={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0},
y axis line style={blue},
ytick style={blue},
yticklabel style={blue},
axis x line*=bottom,
axis y line*=left,    
tick align = outside,]
\addplot [
color=blue,
solid,
line width=0.5pt,
mark size=2.5pt,
mark size=2.5pt,
mark=square*,
mark options={solid,,rotate=180,fill=blue}]
table[row sep=crcr]{
1 4\\
4 6\\
8 8.8\\
12 2.8\\
24 8.162\\};
\end{axis}
\end{tikzpicture}%
\end{document}
Thank you very much

Best regards
User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Tweaking some parts of a chart

Post by Stefan Kottwitz »

You could put each one between \begin{tikzpicture} ... \end{tikzpicture} into a cell of such a tabular, just separated by & (column separator) or \\ (end of line).

Here it's after midnight, I'm off for tonight.

See you,

Stefan
LaTeX.org admin
Post Reply