<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/sjplot-update-bw-figures-for-print-journals-and-package-vignettes-rstats-dataviz/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://strengejacke.wordpress.com/2017/02/06/sjplot-update-bw-figures-for-print-journals-and-package-vignettes-rstats-dataviz/"> R – Strenge Jacke!</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>My <strong>sjPlot-package</strong> was just <a target="_blank" rel="nofollow" href="https://cran.r-project.org/package=sjPlot">updated on CRAN</a> with some – as I think – useful new features.</p>
<p>First, I have added some vignettes to the package (based on the existing <a target="_blank" rel="nofollow" href="http://strengejacke.de/sjPlot/">online-documentation</a>) that cover some core features and principles of the sjPlot-package, so you have direct access to these manuals within R. The vignettes are also online <a target="_blank" rel="nofollow" href="https://cran.r-project.org/package=sjPlot">on CRAN</a>.</p>
<p>A second feature is the better support for black &amp; white figures. There are two ways to create plots in black and white or greyscale. For bar plots, <code>geom.colors = &quot;gs&quot;</code> creates a plot using a greyscale (based on <code>scales::grey_pal()</code>).</p>
<pre>library(sjPlot)
library(sjmisc)
library(ggplot2)
theme_set(theme_bw())
data(efc)
sjp.grpfrq(efc$e42dep, efc$c172code, geom.colors = &quot;gs&quot;)</pre>
<p><a target="_blank" rel="nofollow" href="https://i2.wp.com/strengejacke.files.wordpress.com/2017/02/barplot-gs.png?ssl=1"><img sizes="(max-width: 616px) 100vw, 616px" data-image-description="" data-orig-file="https://strengejacke.files.wordpress.com/2017/02/barplot-gs.png" data-orig-size="672,480" data-image-title="barplot-gs" data-comments-opened="1" class="wp-image-1224" data-recalc-dims="1" data-attachment-id="1224" data-permalink="https://strengejacke.wordpress.com/2017/02/06/sjplot-update-bw-figures-for-print-journals-and-package-vignettes-rstats-dataviz/barplot-gs/" alt="barplot-gs" data-medium-file="https://strengejacke.files.wordpress.com/2017/02/barplot-gs.png?w=300" data-large-file="https://i2.wp.com/strengejacke.files.wordpress.com/2017/02/barplot-gs.png?resize=456%2C326&amp;ssl=1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" src="https://i2.wp.com/strengejacke.files.wordpress.com/2017/02/barplot-gs.png?resize=456%2C326&ssl=1"></a></p>
<p>Similar to barplots, lineplots can be plotted in greyscale as well (with <code>geom.colors = &quot;gs&quot;</code>). However, in most cases lines colored in greyscale are difficult to distinguish. In this case, certain plot types in sjPlot support black &amp; white figures with different line<em>types</em>.</p>
<p>Following plot-types allow black &amp; white figures:</p>
<ul>
<li>sjp.grpfrq(type = „line“)</li>
<li>sjp.int()</li>
<li>sjp.lm(type = „pred“)</li>
<li>sjp.glm(type = „pred“)</li>
<li>sjp.lmer(type = „pred“)</li>
<li>sjp.glmer(type = „pred“)</li>
</ul>
<p>Use <code>geom.colors = &quot;bw&quot;</code> to create a b/w-plot.</p>
<pre># create binrary response
y &lt;- ifelse(efc$neg_c_7 &lt; median(na.omit(efc$neg_c_7)), 0, 1)
# create data frame for fitting model
df &lt;- data.frame(
  y = to_factor(y),
  sex = to_factor(efc$c161sex),
  dep = to_factor(efc$e42dep),
  barthel = efc$barthtot,
  education = to_factor(efc$c172code)
)
# set variable label for response
set_label(df$y) &lt;- &quot;High Negative Impact&quot;
# fit model
fit &lt;- glm(y ~., data = df, family = binomial(link = &quot;logit&quot;))
# print predicted propbabilities
sjp.glm(fit, type = &quot;pred&quot;, vars = c(&quot;barthel&quot;, &quot;sex&quot;,&quot;dep&quot;), geom.colors = &quot;bw&quot;)</pre>
<p><a target="_blank" rel="nofollow" href="https://i1.wp.com/strengejacke.files.wordpress.com/2017/02/line-bw.png?ssl=1"><img sizes="(max-width: 616px) 100vw, 616px" data-image-description="" data-orig-file="https://strengejacke.files.wordpress.com/2017/02/line-bw.png" data-orig-size="672,480" data-image-title="line-bw" data-comments-opened="1" class="wp-image-1226" data-recalc-dims="1" data-attachment-id="1226" data-permalink="https://strengejacke.wordpress.com/2017/02/06/sjplot-update-bw-figures-for-print-journals-and-package-vignettes-rstats-dataviz/line-bw/" alt="line-bw" data-medium-file="https://strengejacke.files.wordpress.com/2017/02/line-bw.png?w=300" data-large-file="https://i1.wp.com/strengejacke.files.wordpress.com/2017/02/line-bw.png?resize=456%2C326&amp;ssl=1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" src="https://i1.wp.com/strengejacke.files.wordpress.com/2017/02/line-bw.png?resize=456%2C326&ssl=1"></a></p>
<p>Different linetypes do not apply to other linetyped plots (like <code>sjp.lm(type = &quot;eff&quot;)</code> or <code>sjp.lm(type = &quot;slope&quot;)</code>), because these usually only plot a single line – so there’s no need for different linetypes, you can just set <code>geom.colors = &quot;black&quot;</code> (or <code>geom.colors = &quot;bw&quot;</code>).</p>
<p>With this new feature, it’s pretty easy to create plots for (print) journals that require b/w or greyscaled figures.</p>
<p> Tagged: <a target="_blank" rel="nofollow" href="https://strengejacke.wordpress.com/tag/data-visualization/">data visualization</a>, <a target="_blank" rel="nofollow" href="https://strengejacke.wordpress.com/tag/ggplot/">ggplot</a>, <a target="_blank" rel="nofollow" href="https://strengejacke.wordpress.com/tag/r/">R</a>, <a target="_blank" rel="nofollow" href="https://strengejacke.wordpress.com/tag/rstats/">rstats</a>, <a target="_blank" rel="nofollow" href="https://strengejacke.wordpress.com/tag/sjplot/">sjPlot</a> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/strengejacke.wordpress.com/1223/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/strengejacke.wordpress.com/1223/" border="0"></a> <img alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" border="0" data-recalc-dims="1"></p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://strengejacke.wordpress.com/2017/02/06/sjplot-update-bw-figures-for-print-journals-and-package-vignettes-rstats-dataviz/"> R – Strenge Jacke!</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/a5pv2Daa-Aw"></a></div>