bbc / bbplot Goto Github PK
View Code? Open in Web Editor NEWR package that helps create and export ggplot2 charts in the style used by the BBC News data team
R package that helps create and export ggplot2 charts in the style used by the BBC News data team
Finalise_plot function is unable to open my png image. I haven't changed any of the code and the image I have is called placeholder.png. Unsure as to why it doesn't work. Any suggestions?
See the attached screenshot.
<img width="1415" alt="Screen Shot 2020-05-17 at 1 30 23 PM" src="https://user-images.githubusercontent.com/65510741/82159476-28070180-9843-11ea-8433-d70ccf3045c5.png"
Cool book. Just a suggestion here:
ggplot(bar_df,
aes(x = reorder(country, lifeExp), y = lifeExp, fill = country == "Mauritius")) +
geom_col() +
scale_fill_manual(values = c("#dddddd", "#1380A1"), guide = F) +
geom_hline(yintercept = 0, size = 1, colour="#333333") +
bbc_style() +
coord_flip() +
labs(title="Reunion is highest",
subtitle = "Highest African life expectancy, 2007") +
theme(panel.grid.major.x = element_line(color="#cbcbcb"),
panel.grid.major.y = element_blank())
When finalizing a plot, it would be nice to be able to pull a logo from a URL. This would make it easier to share code examples without first requiring users to download the logos.
Windows does not have it's own Helvetica font, which results in warnings when using bbc_style() on a typical windows computer.
Running windowsFonts(Helvetica = "TT Arial")
at the start of the script will use the windows default of treating Helvetica as Arial and avoid the warnings.
I'm trying to install bbplot and received the following error messages:
Error: Failed to install 'bbplot' from GitHub:
(converted from warning) unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.5:
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.5/PACKAGES'
The code that I used was:
install.packages('devtools')
devtools::install_github('bbc/bbplot')
I'm using R 3.5.3 (2019-03-11) on a Windows 10 Enterprise machine. I get a code 404 error messages when I try to go to the URLs in the above error message.
Any suggestions would be great. Thanks.
Windows machines do not support Helvetica font type, so I had to make modifications to the bbc_style()
in a separate ggplot2()
function. It would be cool to have maybe a font
argument that defaults to Helvetica, but would allow others to change the font name. Once the font changes, there may be some sizing differences, so it would also be cool to create an offset
size, to do a plus or minus the current font sizes used in your function: bbc_style <- function(font = "Helvetica", offset = 0)
, which would allow me to use it like this: bbc_style("Arial", -2)
.
The bbc_style
function seems very similar to any other ggplot
theme function, like the theme_grey
, theme_classic
, theme_light
, etc., built in to the ggplot2
package, or many others like those in the ggthemes
package.
Except the name.
I think it'd be great to change the name of the function to theme_bbc
if you'd like greater visibility consider submitting it to ggthemes
. With theme_economist
, theme_fivethirtyeight
, and theme_wsj
, theme_bbc
would feel right at home :)
Downloading GitHub repo bbc/bbplot@master
Error in untar2(tarfile, files, list, exdir) : incomplete block on file
I was reading your https://bbc.github.io/rcookbook/ and this is pretty great, but there's an easy step that you could take that would add simplicity and consistency to the plot making process: Take a look at RColorBrewer... it let's you very simply to call out colors as per a variety of themes... perhaps something like this could be done w/ BBC colours? This way one would never have to read a theme sheet, it would be built right in. Helpful?
Hi, can you help me? I can't install the bbplot and it shows an error like this:
Error: Failed to install 'bbplot' from GitHub:
(converted from warning) unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.6:
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.6/PACKAGES'
The dataframe used to plot the example, line_df
is not defined.
Perhaps create an example df and save to the package, or provide code in .md to create line_df
.
Error in (function (el, elname) :
"plot.subtitle" is not a valid theme element name.
I was trying to create a stacked barplot however i encountered this error.
if I use the function bbc_style()
, Chinese characters cannot show properly in the final graphic even when I add theme(text = element_text(family = "Kai"))
.
Delete bbc_style()
can work properly.
So I think there may be some problem with bbc_style()
when using Chinese characters.
Hi!
I've been using this package today to try it out and I am very happy with it.
I have a logo image that I want to add to my plot. I used the logo_image_path option in the finalise_plot function.
The logo is added to the plot, but it is not complete, it is cutted on the right side.
Is there a way to have it complete without having to change the dimensions of the image?
Thank you,
Carlotta.
Hi,
I've started using the bbplot package today which is generally working really well. However, when finalising the plot, the exports seem to include a black bar at the bottom of the image which masks the source details. I've fiddled with the code and it seems to be happening when the subtitle or source are longer than a certain number of characters (although still less wide than the width of the available space). I can't get any plots to finalise with both a subtitle and source at present.
Code:
svannualcount <- ggplot(svkc_count, aes(x = as.character(Recorded_Year), y = n)) +
geom_col(fill="#082a52") +
geom_hline(yintercept = 0, size = 1, colour="#333333") +
theme(axis.text.x = element_text(angle = 0)) +
bbc_style() +
labs(title="This is a test title",
subtitle = "Can you read my test title?")
finalise_plot(plot_name = svannualcount,
source = "Source: This is a test source.",
save_filepath = "/tmp/svkcannualplot.png",
width_pixels = 640,
height_pixels = 450,
logo_image_path = "/tmp/vrulogo.png"
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.