Skip to content

Commit

Permalink
fix code for currently released colorspace package
Browse files Browse the repository at this point in the history
  • Loading branch information
clauswilke committed Apr 19, 2019
1 parent 730a146 commit fe4da7a
Show file tree
Hide file tree
Showing 54 changed files with 60 additions and 238 deletions.
6 changes: 5 additions & 1 deletion aesthetic_mapping.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,11 @@ Both Figures \@ref(fig:temp-normals-vs-time) and \@ref(fig:four-locations-temps-
p_mtcars <- ggplot(mtcars, aes(disp, mpg, fill = hp, shape = factor(cyl), size = wt)) +
geom_point(color = "white") +
scale_shape_manual(values = c(23, 24, 21), name = "cylinders") +
scale_fill_continuous_sequential(palette = "Emrld", name = "power (hp)", breaks = c(100, 200, 300)) +
scale_fill_continuous_sequential(
palette = "Emrld", name = "power (hp)",
breaks = c(100, 200, 300),
rev = FALSE
) +
xlab("displacement (cu. in.)") +
ylab("fuel efficiency (mpg)") +
guides(
Expand Down
2 changes: 1 addition & 1 deletion color_basics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ p1 <- gg_color_swatches(7, title_family = dviz_font_family) +
scale_fill_brewer(type = "seq", palette = "Blues", direction = -1) + ggtitle("ColorBrewer Blues") +
theme(plot.margin = margin(7, 1.5, 7, 1.5))
p2 <- gg_color_swatches(7, title_family = dviz_font_family) +
scale_fill_discrete_sequential("Heat") + ggtitle("Heat") +
scale_fill_discrete_sequential("Heat", rev = FALSE) + ggtitle("Heat") +
theme(plot.margin = margin(7, 1.5, 7, 1.5))
p3 <- gg_color_swatches(7, title_family = dviz_font_family) +
scale_fill_viridis_d() + ggtitle("Viridis") +
Expand Down
7 changes: 5 additions & 2 deletions directory_of_visualizations.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,11 @@ p7 <- ggplot(df_props, aes(x = fct_rev(group), y = value)) +
p8 <- ggplot(filter(df_multi_amounts, x != 1), aes(x, y = factor(type, levels = c("A", "C", "B")), fill = y)) +
geom_tile(color = palette[5], size = 1.5) +
scale_fill_continuous_sequential(h1 = 71, c1 = 80, c2 = 10, l1 = 18, l2 = 97, p1 = 1.5,
begin = 0.2, end = 0.75) +
scale_fill_continuous_sequential(
h1 = 71, c1 = 80, c2 = 10, l1 = 18, l2 = 97, p1 = 1.5,
begin = 0.2, end = 0.75,
rev = FALSE
) +
labs(title = "Heatmap") +
theme_plot_icon_blank(palette[npal], palette[1])
Expand Down
2 changes: 0 additions & 2 deletions docs/aesthetic-mapping.html
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,6 @@ <h2><span class="header-section-number">2.2</span> Scales map data values onto a
</p>
</div>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
<h3>References</h3>
Expand Down
7 changes: 0 additions & 7 deletions docs/aesthetic_mapping.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```


# (PART\*) Part I: From data to visualization {-}
Expand Down
7 changes: 0 additions & 7 deletions docs/avoid_line_drawings.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```


# Avoid line drawings {#avoid-line-drawings}
Expand Down
2 changes: 0 additions & 2 deletions docs/balance-data-context.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,6 @@ <h2><span class="header-section-number">23.4</span> Summary</h2>
<p>Both overloading a figure with non-data ink and excessively erasing non-data ink can result in poor figure design. We need to find a healthy medium, where the data points are the main emphasis of the figure while sufficient context is provided about what data is shown, where the points lie relative to each other, and what they mean.</p>
<p>With respect to backgrounds and background grids, there is no one choice that is preferable in all contexts. I recommend to be judicious about grid lines. Think carefully about which specific grid or guide lines are most informative for the plot you are making, and then only show those. I prefer minimal, light grids on a white background, since white is the default neutral color on paper and supports nearly any foreground color. However, a shaded background can help the plot appear as a single visual entity, and this may be particularly useful in small multiples plots. Finally, we have to consider how all these choices relate to visual branding and identity. Many magazines and websites like to have an immediately recognizable in-house style, and a shaded background and specific choice of background grid can help create a unique visual identity.</p>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
<h3>References</h3>
Expand Down
7 changes: 0 additions & 7 deletions docs/balance_data_context.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```

# Balance the data and the context {#balance-data-context}

Expand Down
2 changes: 0 additions & 2 deletions docs/boxplots-violins.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,6 @@ <h2><span class="header-section-number">9.2</span> Visualizing distributions alo
</p>
</div>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
<h3>References</h3>
Expand Down
7 changes: 0 additions & 7 deletions docs/boxplots_violins.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```

# Visualizing many distributions at once {#boxplots-violins}

Expand Down
2 changes: 0 additions & 2 deletions docs/choosing-visualization-software.html
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,6 @@ <h2><span class="header-section-number">28.3</span> Separation of content and de
<p>Separation of content and design allows data scientists and designers to each focus on what they do best. Most data scientists are not designers, and therefore their primary concern should be the data, not the design of a visualization. Likewise, most designers are not data scientists, and they should be able provide a unique and appealing visual language for figures without having to worry about specific data, appropriate transformations, and so on. The same principle of separating content and design has long been followed in the publishing world of books, magazines, newspapers, and websites, where writers provide content but not layout or design. Layout and design are created by a separate group of people who specialize in this area and who ensure that the publication appears in a visually consistent and appealing style. This principle is logical and useful, but it is not yet that widespread in the data visualization world.</p>
<p>In summary, when choosing your visualization software, think about how easily you can reproduce figures and redo them with updated or otherwise changed datasets, whether you can rapidly explore different visualizations of the same data, and to what extent you can tweak the visual design separately from generating the figure content. Depending on your skill level and comfort with programming, it may be beneficial to use different visualization tools at the data exploration and the data presentation stages, and you may prefer to do the final visual tweaking interactively or by hand. If you have to make figures interactively, in particular with a software that does not keep track of all data transformations and visual tweaks you have applied, consider taking careful notes on how you make each figure, so that all your work remains reproducible.</p>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
</section>
Expand Down
7 changes: 0 additions & 7 deletions docs/choosing_visualization_software.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```

# Choosing the right visualization software {#choosing-visualization-software}

Expand Down
2 changes: 0 additions & 2 deletions docs/color-basics.html
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,6 @@ <h2><span class="header-section-number">4.3</span> Color as a tool to highlight<
</p>
</div>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;sf&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
Expand Down
2 changes: 0 additions & 2 deletions docs/color-pitfalls.html
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,6 @@ <h2><span class="header-section-number">19.3</span> Not designing for color-visi
</p>
</div>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
<h3>References</h3>
Expand Down
7 changes: 0 additions & 7 deletions docs/color_basics.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```

# Color scales {#color-basics}

Expand Down
2 changes: 0 additions & 2 deletions docs/coordinate-systems-axes.html
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,6 @@ <h2><span class="header-section-number">3.3</span> Coordinate systems with curve
</p>
</div>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
</section>
Expand Down
7 changes: 0 additions & 7 deletions docs/coordinate_systems_axes.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```

# Coordinate systems and axes {#coordinate-systems-axes}

Expand Down
2 changes: 0 additions & 2 deletions docs/directory-of-visualizations.html
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,6 @@ <h2><span class="header-section-number">5.6</span> Uncertainty</h2>
<p><img src="directory_of_visualizations_files/figure-html/confidence-bands-1.png" width="685.714285714286" style="display: block; margin: auto;" /></p>
<p>For smooth line graphs, the equivalent of an error bar is a confidence band (Chapter <a href="visualizing-uncertainty.html#uncertainty-curve-fits">16.3</a>). It shows a range of values the line might pass through at a given confidence level. As in the case of error bars, we can draw graded confidence bands that show multiple confidence levels at once. We can also show individual fitted draws in lieu of or in addition to the confidence bands.</p>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
</section>
Expand Down
8 changes: 0 additions & 8 deletions docs/directory_of_visualizations.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```

```
## Warning: package 'sf' was built under R version 3.5.2
```
Expand Down
2 changes: 0 additions & 2 deletions docs/ecdf-qq.html
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,6 @@ <h2><span class="header-section-number">8.3</span> Quantile–quantile plots</h2
</p>
</div>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
<h3>References</h3>
Expand Down
2 changes: 0 additions & 2 deletions docs/figure-titles-captions.html
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,6 @@ <h2><span class="header-section-number">22.3</span> Tables</h2>
<p>When authors draw tables with horizontal lines between data rows, the intent is usually to help the eye follow individual lines. However, unless the table is very wide and sparse, this visual aid is not normally needed. We don’t draw horizontal lines between rows in a piece of regular text either. The cost of horizontal (or vertical) lines is visual clutter. Compare parts (a) and (c) of Figure <a href="figure-titles-captions.html#fig:table-examples">22.7</a>. Part (c) is much easier to read than part (a). If we feel that a visual aid separating table rows is necessary, then alternating lighter and darker shading of rows tends to work well without creating much clutter (Figure <a href="figure-titles-captions.html#fig:table-examples">22.7</a>d).</p>
<p>Finally, there is a key distinction between figures and tables in where the caption is located relative to the display item. For figures, it is customary to place the caption underneath, whereas for tables it is customary to place it above. This caption placement is guided by the way in which readers process figures and tables. For figures, readers tend to first look at the graphical display and then read the caption for context, hence the caption makes sense below the figure. By contrast, tables tend to be processed like text, from top to bottom, and reading the table contents before reading the caption will frequently not be useful. Hence, captions are placed above the table.</p>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
<h3>References</h3>
Expand Down
7 changes: 0 additions & 7 deletions docs/figure_titles_captions.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```

# Titles, captions, and tables {#figure-titles-captions}

Expand Down
2 changes: 0 additions & 2 deletions docs/histograms-density-plots.html
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,6 @@ <h2><span class="header-section-number">7.2</span> Visualizing multiple distribu
</p>
</div>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
</section>
Expand Down
2 changes: 0 additions & 2 deletions docs/image-file-formats.html
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,6 @@ <h2><span class="header-section-number">27.3</span> Converting between image for
<p>It is generally possible to convert any image format into any other image format. For example, on a Mac, you can open an image with Preview and then export to a number of different formats. In this process, though, important information can get lost, and information is never regained. For example, after saving a vector graphic into a bitmap format, e.g. a pdf file as a jpeg, the resolution independence that is a key feature of the vector graphic has been lost. Conversely, saving a jpeg image into a pdf file does not magically turn the image into a vector graphic. The image will still be a bitmap image, just stored inside the pdf file. Similarly, converting a jpeg file into a png file does not remove any artifacts that may have been introduced by the jpeg compression algorithm.</p>
<p>It is therefore a good rule of thumb to always store the original image in the format that maintains maximum resolution, accuracy, and flexibility. Thus, for data visualizations, either create your figure as pdf and then convert into png or jpg when necessary, or alternatively store as high-resolution png. Similarly, for images that are only available as bitmaps, such as digital photographs, store them in a format that doesn’t use lossy compression, or if that can’t be done, compress as little as possible. Also, store the image in as high a resolution as possible, and downscale when needed.</p>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
</section>
Expand Down
7 changes: 0 additions & 7 deletions docs/image_file_formats.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```

# (PART\*) Part III: Miscellaneous topics {-}

Expand Down
2 changes: 0 additions & 2 deletions docs/introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ <h2>Ugly, bad, and wrong figures</h2>
<p>I am not explicitly labeling good figures. Any figure that isn’t clearly labeled as flawed should be assumed to be at least acceptable. It is a figure that is informative, looks appealing, and could be printed as is. Note that among the good figures, there will still be differences in quality, and some good figures will be better than others.</p>
<p>I generally provide my rationale for specific ratings, but some are a matter of taste. In general, the “ugly” rating is more subjective than the “bad” or “wrong” rating. Moreover, the boundary between “ugly” and “bad” is somewhat fluid. Sometimes poor design choices can interfere with human perception to the point where a “bad” rating is more appropriate than an “ugly” rating. In any case, I encourage you to develop your own eye and to critically evaluate my choices.</p>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>

Expand Down
7 changes: 0 additions & 7 deletions docs/introduction.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```


# Introduction {#introduction}
Expand Down
2 changes: 0 additions & 2 deletions docs/multi-panel-figures.html
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,6 @@ <h2><span class="header-section-number">21.2</span> Compound figures</h2>
</p>
</div>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
<h3>References</h3>
Expand Down
2 changes: 0 additions & 2 deletions docs/no-3d.html
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,6 @@ <h2><span class="header-section-number">26.3</span> Appropriate use of 3D visual
</p>
</div>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>

Expand Down
2 changes: 0 additions & 2 deletions docs/overlapping-points.html
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,6 @@ <h2><span class="header-section-number">18.3</span> Contour lines</h2>
</div>
<p>We can make out two main trends. First, the better cuts (very good, premium, ideal) tend to have lower carat values than the poorer cuts (fair, good). Recall that carat is a measure of diamond weight (1 carat = 0.2 gram). Better cuts tend to result (on average) in lighter diamonds because more material needs to be removed to create them. Second, at the same carat value, better cuts tend to command higher prices. To see this pattern, look for example at the price distribution for 0.5 carat. The distribution is shifted upwards for better cuts, and in particular it is substantially higher for diamonds with ideal cut than for diamonds with fair or good cut.</p>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
<h3>References</h3>
Expand Down
7 changes: 0 additions & 7 deletions docs/overlapping_points.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```

# Handling overlapping points {#overlapping-points}

Expand Down
7 changes: 0 additions & 7 deletions docs/pitfalls_of_color_use.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```

# Common pitfalls of color use {#color-pitfalls}

Expand Down
2 changes: 0 additions & 2 deletions docs/preface.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ <h2>Acknowledgments</h2>
<p>Several people have provided helpful feedback on draft versions of this book. Most importantly, Mike Loukides, my editor at O’Reilly, and Steve Haroz have both read and commented on every chapter. I also received helpful comments from Carl Bergstrom, Jessica Hullman, Matthew Kay, Edzer Pebesma, Tristan Mahr, Jon Schwabish, and Hadley Wickham. Len Kiefer’s blog and Kieran Healy’s book and blog postings have provided numerous inspirations for figures to make and datasets to use. A number of people pointed out minor issues or typos, including Thiago Arrais, Malcolm Barrett, Jessica Burnett, Jon Calder, Antônio Pedro Camargo, Daren Card, Kim Cressman, Akos Hajdu, Andrew Kinsman, Will Koehrsen, Alex Lalejini, John Leadley, Katrin Leinweber, Mikel Madina, Claire McWhite, S’busiso Mkhondwane, Jose Nazario, Steve Putman, Maëlle Salmon, Christian Schudoma, James Scott-Brown, Enrico Spinielli, Wouter van der Bijl, and Ron Yurko.</p>
<p>I would also more broadly like to thank all the other contributors to the tidyverse and the R community in general. There truly is an R package for any visualization challenge one may encounter. All these packages have been developed by an extensive community of thousands of data scientists and statisticians, and many of them have in some form contributed to the making of this book.</p>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
</section>
Expand Down
2 changes: 0 additions & 2 deletions docs/proportional-ink.html
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,6 @@ <h2><span class="header-section-number">17.3</span> Direct area visualizations</
</p>
</div>

<pre><code>## Warning: package &#39;ggplot2&#39; was built under R version 3.5.2</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.5.2</code></pre>
</div>
</div>
<h3>References</h3>
Expand Down
7 changes: 0 additions & 7 deletions docs/proportional_ink.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```


# (PART\*) Part II: Principles of figure design {-}
Expand Down
7 changes: 0 additions & 7 deletions docs/redundant_coding.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

```
## Warning: package 'ggplot2' was built under R version 3.5.2
```

```
## Warning: package 'dplyr' was built under R version 3.5.2
```


# Redundant coding {#redundant-coding}
Expand Down
Loading

0 comments on commit fe4da7a

Please sign in to comment.