Comments (7)
Looks like you have a +
at the beginning of line 10 that shouldn't be there
from bbplot.
This code runs fine. What's different from yours? When you say you tried what I suggest, what did you try? When you're having unexpected results in R, another good approach is to restart your R session and try running again (under the Session
menu in RStudio). (Note that I removed the devtools::install_github('bbc/bbplot')
line because you don't need to reinstall the package every time you run the code.)
pacman::p_load('dplyr', 'tidyr', 'gapminder',
'ggplot2', 'ggalt',
'forcats', 'R.utils', 'png',
'grid', 'ggpubr', 'scales',
'bbplot')
line_df <- gapminder %>%
filter(country == "Malawi")
#Make plot
line <- ggplot(line_df, aes(x = year, y = lifeExp)) +
geom_line(colour = "#1380A1", size = 1) +
geom_hline(yintercept = 0, size = 1, colour="#333333") +
bbc_style() +
labs(title="Living longer",
subtitle = "Life expectancy in Malawi 1952-2007")
line
Created on 2020-05-18 by the reprex package (v0.3.0)
from bbplot.
Dude, you're the man. Thanks so much!
from bbplot.
Thanks. I tried that but it didn't work. I'm knew to R so I must have missed a step along the way.
from bbplot.
I got it to work when I put: plot (line <-
One more question. How do I get R to pull an image-logo from my files in the final line of code. I've tried using a web link to our website, but also .png from my harddrive. Do I need to load the image first? Possibly the image I'm using is just too big, but I didn't think that makes sense considering it's a .png vector
finalise_plot(plot_name = my_line_plot,
source = "Source: Gapminder",
save_filepath = "filename_that_my_plot_should_be_saved_to.
png",
width_pixels = 640,
height_pixels = 450,
logo_image_path = "
from bbplot.
Here's the actual code that I can't get to plot:
plot (finalise_plot(plot_name = "line",
source = "Source: Gapminder",
save_filepath = "Malawi.png",
width_pixels = 640,
height_pixels = 450,
logo_image_path = "~Orionlogo.png"))
from bbplot.
Ok, let's take a step back here because you have a few things going on at once.
First, wrapping plot()
around your code is not responsible for fixing your previous issue. It is also unnecessary, and I do not recommend it. What's happening underneath the hood is that plot()
is explicitly printing the object. If you've got code that saves to an object (line <- #{some plot code}
, it won't print by default. You need to look at line
by running it either in a script or in the console pane. If you look at the code I put above, line
, the plot object we created, is the last thing to run. That's why it printed the plot.
Moving on to your second question, finalise_plot()
shouldn't work with plot()
, as it is trying to save a file (Malawi.png
), not plot something in your R session. So remove that part surrounding it.
Second, you have plot_name = "line"
but it should be plot_name = line
. Because line
is an object that lives in your R session, you don't need to wrap it in quotation marks. I can't tell you if your company logo will work here because I don't have the file, and I don't know where it is on your computer in relation to your R session. But if it's at "~Orionlogo.png" it should now appear on the plot in the file Malawi.png
.
Since this is getting a little more detailed, I'm also going to skip ahead to something I was going to bring up after we resolved your issue, which is that GitHub issues are not generally a good place to ask questions like this. You might like asking for help at a place like RStudio Community. Additionally, you can maximize your chances of getting help by sharing your code in a reproducible example. Here is a good guide on preparing R questions, as well as a list of places that are good for asking for help: https://www.tidyverse.org/help/
If these don't fix your issue, my recommendation would be to post at RStudio Community. You can feel free to tag me (my username is malcolm
there) for help. The reason I am suggesting that is that GitHub issues is generally a place to file bug reports or feature requests, which this is not.
So if this doesn't solve your problem, please close this issue and ask for help there (maybe with a link to this issue).
from bbplot.
Related Issues (18)
- Windows Fonts
- failed install file incomplete HOT 2
- line_df not defined in README.md HOT 3
- Suggestion for "Color bars Conditionally" example in the cookbook.
- "plot.subtitle" is not a valid theme element name. HOT 1
- Error Failed to install bbplot from GitHub HOT 1
- Suggestion: Add code examples to produce chart examples
- Logo_Image_Path not working as expected
- Cannot install the bbplot HOT 4
- Error in png::readPNG(logo_image_path): unable to open /placeholder.png
- Black bar at bottom of plot HOT 1
- Incongrous function name HOT 2
- Add a set of color palettes HOT 1
- The graphic can not show chinese
- Installation issues
- Allow the use of logos from the internet
- [Feature request] - Add arguments to bbc_style() for easy customization HOT 3
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 bbplot.