# Modifying some features in a scatter plot

I would like to have the following modifications to the scatter plot.

The title should be typeset on two lines.

I would like a break on each axis indicating a skip from 0. (When I was in junior high school, we used two 'parallel" wavy lines.)

0 should be put in the lower left corner of the plot.

Remove the comma in the years.

I also have some question. Why is the plot drawn in blue? What is the diameter of each dot? How would I make the line connecting the dots to be dashed and drawn in a different shade of blue?

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}

\begin{axis}[grid=major, title=\textbf{Population of Pittsford in \boldmath$19^{\mathrm{th}}$ Century\unboldmath},
ylabel = Population (in thousands),
xlabel = Year,
xmax=1900]

\addplot plot coordinates{(1800,1.1) (1810,1) (1820,0.9) (1830,1.2) (1840,1.5) (1850,1.5) (1860,1.5) (1870,1.7) (1880,1.75) (1890,1.75) (1900,1.9)};
\coordinate (Bottom Left) at (axis cs:1800,0);
\coordinate (Bottom Right) at ($(Bottom Left) + (axis direction cs:100,0)$);
\draw (Bottom Left) -- (Bottom Right);
\coordinate (Top Left) at ($(Bottom Left) + (axis direction cs:0,0.1)$);
\coordinate (Top Right) at ($(Top Left) + (axis direction cs:20,0)$);
\draw[red,thick] (Top Left) -- (Top Right);

\end{axis}

\end{tikzpicture}

\end{document}


First of, I think you should go with percusse's solution. But as per your explicit request, here you go:

1. I have no clue how to redefine the axis x discontinuity and axis y discontinuity to use smaller lines or to use them only left and bottom (instead of right and top too). So that's why I don't use them at all.
2. You don't need tick marks as you already have the grid=major. So I added ytick style = {draw=none}, xtick style = {draw=none} to get rid of them.
3. As to the rotations of your labels: you don't need a tick label style = {} inside another tick label style = {}. Just go for yticklabel style = {font=\tiny, fill=white, rotate=0}, xticklabel style = {font=\tiny, fill=white, rotate=-45}
4. So now for the discontinuities: I put them on top of your plot as extra ticks That's certainly a bad way to do it, but it makes it look the way you want it to look. Also it involves a lot of trial and error to find the "right" values for xshift and yshift:

Code:

\documentclass[tikz,border=2mm]{standalone}
\usepackage{pgfplots}

\def\discon{$\wr\!\!\!\wr$}

\begin{document}
\begin{tikzpicture}
\begin{axis}[   grid                = major,
/pgf/number format/1000 sep = {},
title               = Population of Pittsford in \\ 19\textsuperscript{th} Century,
title style         = {align=center,font=\bfseries},
ylabel              = Population (in thousands),
xlabel              = Year,
xmin                = 1790,
xmax                = 1900,
xtick               = {1800,1810,...,1900},
ytick style         = {draw=none},
xtick style         = {draw=none},
yticklabel style    = {font=\tiny, fill=white},
xticklabel style    = {font=\tiny, fill=white, rotate=-45},
ymin                = 0.6,
ymax                = 2,
ytick               = {0.8, 1, ..., 2},
extra x ticks       = {1792},
extra x tick style  = {grid=none, xticklabel style={yshift=1.3mm, rotate=45, inner sep=.5pt}},
extra x tick labels = {\discon},
extra y ticks       = {0.7},
extra y tick style  = {grid=none, yticklabel style={xshift=1.1mm, rotate=90, inner sep=.5pt}},
extra y tick labels = {\discon}]
\addplot plot coordinates{(1800,1.1) (1810,1) (1820,0.9) (1830,1.2) (1840,1.5) (1850,1.5) (1860,1.5) (1870,1.7) (1880,1.75) (1890,1.75) (1900,1.9)};
\end{axis}
\end{tikzpicture}
\end{document}


1. \def\discon{$\wr\!\!\!\wr$}: This defines a new command \discon which I use as the symbol for discontinuities. It is build by using two \wr (in mathmode). The \! (negative thin space (normally −1/6 of a quad)) takes care of the spacing between those two \wr.
2. About the rotation: I don't know why the rotation happens the way it happens when you put tick label style inside a tick label style. But it's bad syntax, so just use the right syntax and put the rotate inside 1 tick label style instead of in 2.
• This looks how I wanted it. – user74973 Jun 3 '15 at 15:50
• Please explain the syntax of \def\discon{$\wr\!\!\!\wr$},. – user74973 Jun 3 '15 at 15:50
• Why does tick label style={rotate=-45} within xticklabel style= rotate by 45 degrees the labels on the y-axis? I have tick label style={rotate=0} within yticklabel style=. – user74973 Jun 3 '15 at 15:50
• \wr is a "vertical tilde". \!is negative (horizontal) space. The dollar signs make everything math mode. This needs to be mathmode because \wr only works in mathmode. So it is a vertical tilde followed by some negative space (so we are now slightly in front of that vertical tilde) followed by a second tilde. – Maarten Dhondt Jun 3 '15 at 17:20
• No, the rotate=-45 is something you put in there to rotate your x labels. So i used the rotate=45 to counteract your -45. – Maarten Dhondt Jun 3 '15 at 19:23

The y axis doesn't need any discontinuity as it is near to zero already. Also discontinuity on both axes shows that origin is not relevant anyways.

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[/pgf/number format/1000 sep={}]
\begin{axis}[axis y line=left,axis x line=bottom,width=10cm,height=5cm,
grid=major,
title=Population of Pittsford in\\ 19\textsuperscript{th} Century,
title style={align=center,font=\bfseries},
ylabel = Population (in thousands),
xlabel = Year,
xmax=1900,xmin=1790,xtick={1800,1810,...,1900},
ymin=0,ymax=2.5,
axis x discontinuity=parallel,
]


• I originally had title=\textbf{Population of Pittsford \\ in \boldmath$19^{\mathrm{th}}$ Century\unboldmath} with the "\\". I guess that \textbf{} obscured the "\\". I see that I can get the title in bold with the command title style={align=center,font=\bfseries}, and just have the title immediately following title=. – user74973 May 30 '15 at 20:40
• I do want the break on the y-axis. The scatter plot is artificially elevated in your plot. I edited the axis environment to include xmin=1790, and xmax=1900, and xtick={1800,1810,...,1900}, and ymin=0.6, and ymax=2, and ytick={0.8, 1, ..., 2},. There are two mishaps with this, which I have not seen on any other scatter plot. First, the axis break symbol on the y-axis interferes with the axis break symbol on the x-axis. Can I make these parallel lines smaller? Second, the symbol for the breaks in the axes also occurs in my display on the top and right sides. – user74973 May 30 '15 at 20:43
• Also, I include the option xticklabel style={font=\tiny,fill=white, tick label style={rotate=-45}}, so that all the years can be nicely fit along the x-axis. I don't want the numbers along the y-axis tilted. I have yticklabel style={font=\tiny,fill=white, tick label style={rotate=0}}, after the xticklabel command, and the rotation-command is ignored. – user74973 May 30 '15 at 20:44