Comments (7)
Thanks for sending me that link, I had missed that stackoverflow thread :-( The answer by dystroy was as good as you can do with ggplot. You can get the xkcd plot theme by using the following (after downloading Humor Sans and using the extrafont package as discussed in SO)
... + theme_tufte(ticks=FALSE) + theme(text=element_text(family="Humor Sans")
As for the jittered axis lines, the way that they are implemented in that post is the way to do it in ggplot. The only way to make it less hackish is to wrap that hack into a geom. This is why I had to implement Tufte's range frames as geom's rather than it being part of the theme.
Which actually means that I should be able to tweak some code in either geom_rangeframe or geom_rug, from which I adapted range frame, to allow for jittered axis lines. I'll give that a shot and I might either adapt geom_rangeframe or add a new axis line geom.
from ggthemes.
Should I file a bugreport at ggplot2 about the "none-themable" axis lines (both for xkcd style plots and your tufte one)?
It would be really cool if you could just do a + theme_xkcd()
and the plot would be changed without changing any geom_...()
. As far as I understood the hack, themes would also need the ability to set "jitter" for everything which draws a line?!
from ggthemes.
To the extent that I understand ggplot2 and the way it separates concerns, you will always need to mess with the geoms to get xkcd like plotting. The theme does not alter the behavior of the geoms; it only changes the look of background material for the plot. For example, the theme cannot alter the default color of geoms; this is why this package includes color scales with matching themes.
So the xkcd plots cannot be implemented just as a theme in the same way that to make an Economist plot requires both theme_economist() and color_scale_economist().
If you aren't aware of it, check out the function update_geom_defaults. If you do
update_geom_defaults("line", list(position="jitter"))
all future geom_line
lines will be jittered.
It should be possible, to write a function that sets these defaults for the geoms, and the theme, and then produces the plot. The question being how much work it is get enough generality that it adds value beyond just writing the code.
Sorry that I don't have anything more concrete right now. I'll keep thinking about this. I know that the separation between geoms and themes has been a complaint against ggplot. I am thinking that there should be a way to define geom themes which are a collection of geom defaults, and then a way to evaluate ggplot object so that it uses those defaults without changing the global defaults.
from ggthemes.
I would argue that "hand-drawn look" is a thing of themes and therefore there should be a way to affect that via themes:-)
I would also argue that a theme should be able to set default colors and default axis styling: ggplot has a default color scheme and axis style, so just because you want to have it look (consistently) different I have to add a ggplot call to every plot: I would like to do it once and be done with it :-)
I will ask upstream if this would be an idea worth implementing. Let's see what they say :-)
from ggthemes.
I agree; and I think there should be some way to bundle a theme with default values for geoms and a default scales. From a theoretical perspective, since color perception is not independent of the background color, scales are never independent of the theme. I know that Stata themes set values for both background elements and the default colors for the equivalent of geoms. There are some issues in actually implementing this, which i remember reading about in some threads (but I don't fell like looking up right now :-) ). One thing to be aware of, is that all the code for implementing geoms is being rewritten. Maybe it will be easier to implement this in the future.
Last night I was playing around with a couple of ways to create something like a theme for geoms. I might also add functions which combine themes and scales.
from ggthemes.
👍 this would be great
from ggthemes.
Implemented in the xkcd package.
from ggthemes.
Related Issues (20)
- geom_tufteboxplot errors as resolution function from ggplot2 is called
- Convert from travis to github actions HOT 1
- Fix error in tests
- Conditionally load vdiffr so that it complies with suggested package rules
- Rename default branch from master to main HOT 1
- Automatically generate preview of figures on README
- images in main page of pkgdown website are broken HOT 1
- Helpful: page with visualization of themes and names HOT 1
- Themes working with scatter3d.
- `theme_tufte` with `geom_rangeframe` doesn't work with `facet_wrap` HOT 2
- Problems with theme_economist HOT 1
- Not enogh colors on palette "gdocs" HOT 2
- base_family not working in theme_economist() and theme_excel()
- Allow Gradient Scales to Accept Midpoint Arg
- Images are broken on homepage HOT 5
- Plot with `theme_fivethirtyeight()` applied can't be further modified with `{ggplot2}` functions HOT 3
- extended_range_breaks - n= not respected
- images in package home page are broken HOT 2
- Installation fails @ R4.2.1 RHEL
- theme_fivethirtyeight() error on mac HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggthemes.