Comments (4)
Great! This now should be fixed in the dev version you can install with remotes::install_github("eliocamp/ggnewscale@dev")
. Let me know if it works :)
Thanks for the report and the example (I added it as a test).
from ggnewscale.
Thanks. Do you have a reproducible example? ggnewscale is supposed to mimic your solution, but it's possible it needs to do more.
from ggnewscale.
Thanks for the quick reply.
Here is an example which throws the error mentioned above:
library(tidyverse)
library(ggnewscale)
# Manipulate `setup_data()` of `StatYdensity` and store the object as `StatYdensity2`.
StatYdensity2 <- ggproto("StatYdensity2", StatYdensity,
setup_data = function (data, params) {
data <- plyr::ddply(data, c("x", "fill"), within,
# Assign the range of `y` to the newly created column `range`.
assign("range", list(range(y))))
data
})
set.seed(5)
df <- data.frame(
x = floor(runif(100, min=1, max=5)),
y = floor(runif(100, min=1, max=10)),
gender = c("female", "male")[floor(runif(100, min=1, max=3))],
fill = floor(runif(100, min=1, max=5))
)
df %>% ggplot(aes(x, y, fill = gender, group = interaction(x, gender))) +
# Call `geom_violin()` using the manipulated stat `StatYdensity2`.
geom_violin(stat = "ydensity2") +
new_scale_fill() +
geom_point(aes(x, y, fill = fill), shape = 21, inherit.aes = F)
Note that the call of plyr::ddply()
does not make that much sense in this example, however as pointed out earlier, this is the source of the error.
Either applying the solution of the original post or simply calling geom_violin()
instead of geom_violin(stat = "ydensity2")
works like a charm. plyr::ddply()
just isn't happy about the renaming of the variables that takes places due to the call of new_scale_fill()
.
At this point I think it's best to use the solution is already described. I just thought it's not that unusual to use plyr::ddply()
in geoms at some point in general.
Looking forward to hearing about your thoughts on this.
from ggnewscale.
Great, thank you very much.
I am quite busy at the moment, but I will give it a try as soon as can in the next days!
Thanks again and all the best!
from ggnewscale.
Related Issues (20)
- Can't remove guides HOT 1
- guide_legend(ncol=2) HOT 3
- ggplot2 (3.3.5) HOT 2
- Linetype guides got mixed when vertical and horizontal lines are combined HOT 2
- control order of legends? HOT 2
- new_scale_*() position matters HOT 1
- `guides` properties before `new_scale` are not preserved HOT 2
- Release ggnewscale 0.5.0
- Release ggnewscale 0.4.6
- new scale for x/y? HOT 2
- `override.aes` is ignored with `aesthetics = c("fill", "color")` when using `{ggnewscale}` HOT 2
- Release ggnewscale 0.4.7
- Multiple new_scale_fill doesn't work. HOT 9
- Support for plotly HOT 4
- Release ggnewscale 0.4.8
- Issue When Trying to Employ `guide_colourbar` ::::: v0.4.8 HOT 5
- Legend issues when using `guides(...)` HOT 4
- Add ability to name scales HOT 7
- ggnewscale CRAN note HOT 3
- Issues with next version of ggplot2 HOT 4
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 ggnewscale.