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 dear Stefan
Last edited by dasag on Fri Dec 12, 2014 8:40 pm, edited 1 time in total.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

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

Tweaking some parts of a chart

Post by Johannes_B »

As Stefan told and showed you in a code example, the snippet has to go after \pgfplotsset{compat=newest}.

For further reference
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
dasag
Posts: 30
Joined: Wed Dec 10, 2014 3:43 pm

Tweaking some parts of a chart

Post by dasag »

Thank you dear Stefan and dear Johannes_B. You togother help me very much. The end I want to ask: How do that across mark and number 0 was be near near number 2000 as picture which I send you (also send again)

Code: Select all

Code, edit and compile here:
\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\\
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Attachments
OtKRX.jpg
OtKRX.jpg (10.7 KiB) Viewed 4076 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: Tweaking some parts of a chart

Post by Stefan Kottwitz »

Well such a discontinuity marker is meaningful if 0 would actually not be on the axis. But here, it seems, that 0 is on the axis, if I see 0, 2000 and 4000. I don't see a real discontinuity. We can work it out somehow, I just see the discontinuity would not be at this position, i.e. not right at 0 but above. The thing below 0 is not relevant, not part of the axis anyway, so no need to discontinue.
Should not the scaling be different then, i.e. the third axis starts with 0, short discontinuity then it jumps to 1000 or so (that's why the gap!) and continues to 2000, 4000, ... The discontinuity should cover which range? From 0 to 0 or from 0 to 2000 - because it symbolizes a gap. Much words, I just want to understand and want to be clear.

What do you think? Is the current position undesirable? Is that discontinuity exactly at 0 definitely required?

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 »

But discontinuity marker may be in center?0,2000,4000 number and center for example 1ooo discontinuity marker?

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

Re: Tweaking some parts of a chart

Post by Stefan Kottwitz »

Where is the discontinuity? Where's this break? The interval between 0, 2000 and 4000 is continuous. That's because 2000 is in the middle. And below zero, there's nothing in this chart. That's why the marker doesn't make sense in my eyes.

Feel free to post a hand-drawing showing where a discontinuity, gap, jump, anything - until now it's a normal axis, continuous, where there should be a sign without reason, I think.

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

Tweaking some parts of a chart

Post by dasag »

Dear Stefan I send you hand drawing image.

Also I want to ask how do 8 graph in one page:4 graph above, 4 graph below , but in one page.
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.

Code: Select all

Code, edit and compile here:
\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=55}}{}{}
\makeatother
\begin{document}
\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},% 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\\
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Attachments
DasagPlot.jpg
DasagPlot.jpg (56.9 KiB) Viewed 4049 times
Last edited by Johannes_B on Sat Dec 13, 2014 12:45 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: Tweaking some parts of a chart

Post by Stefan Kottwitz »

Ok, so just this symbol at the value 2000. No problem, no matter what it means, I can draw it (but tomorrow). I am still curious what the real meaning of this gap is.

Those 8 graphs could be arranged using the subfig package, minipages, par boxes, or tabular. I guess the last one would be a nice way. Or do you need captions? Numbering? Referencing)

regarding the x-axis issue you could perhaps hand-draw how the axis should finally look like, so we can understand and try.

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

Tweaking some parts of a chart

Post by dasag »

Dear Stefan I send you hand-draw x-axis.
growth.jpg
growth.jpg (34.02 KiB) Viewed 4040 times
Also You can wriyte code which in page 8 graphs for examle this graph-8x

Thank you
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Tweaking some parts of a chart

Post by Stefan Kottwitz »

As you can draw anything on a chart, you can draw lines and gap on your own.

Here's a way.
  • Load the calc library in the preamble after pgfplots: \usetikzlibrary{calc}
  • Define a coordinate within the axis, so you can later refer to it: \coordinate (pos) at (axis cs:198,2000);
  • Draw after the axis has ended, before ending the TikZ picture:

    Code: Select all

    Code, edit and compile here:
    \newcommand*{\len}{0.2}
    \draw[double distance=2.2,double=white,draw=red,thick]
    ($(pos)-(\len,\len)$) -- ($(pos)+(\len,\len)$);
    \renewcommand*{\len}{0.21}
    \draw[double distance=2.2,double=white,draw=white,thin]
    ($(pos)-(\len,\len)$) -- ($(pos)+(\len,\len)$);
    הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I used \len for adjusting the length of the lines. Simply one double line would suffice, I just draw the second line for better cleaning between in white.

Complete Code, my older code commented out:

Code: Select all

Code, edit and compile here:
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{calc}
%\usepackage{etoolbox}
%\makeatletter
%\patchcmd{\pgfplots@drawaxis@lines@preparediscont@for}{ticks,segment length=4pt, amplitude=8pt}%
% {ticks,segment length=4pt, amplitude=5pt,transform={rotate=55}}{}{}
%\makeatother
\begin{document}
\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},% 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]{
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
chart2.png
chart2.png (22.96 KiB) Viewed 4040 times
For the other, new problem with the x axis and the 8 graphs on a page, you can open a new topic for each. Otherwise people hardly find it here at the end of thread which originally dealt with another issue. And we sort by topics, not by "somebody's collected various things". ;)

I may deal with it later, as I am busy right now. (If you keep posting the same at StackExchange, I may leave it to them and stop here).

Stefan
LaTeX.org admin
Post Reply