ricardo-bion / ggradar Goto Github PK
View Code? Open in Web Editor NEWradar charts with ggplot2
Home Page: https://twitter.com/ricardobion
radar charts with ggplot2
Home Page: https://twitter.com/ricardobion
It seams that something is wrong with the current version of R.
Running the example
library(ggradar)
library(dplyr)
library(scales)
library(tibble)
mtcars_radar <- mtcars %>%
as_tibble(rownames = "group") %>%
mutate_at(vars(-group), rescale) %>%
tail(4) %>%
select(1:10)
I had some examples of my own that are not running well now.
Using the latest version from github, the plot appears to work fine but none of the labels show up.
"font family not found in Windows font database"
Hi,
I am trying to figure out, so far unsuccesfully, if it is possible to omit some of the axis from the plot? I.e., I have 32 variables but I would like to only show axis for the main circular degrees (0,45,90,..). I would hope my plot to look something like this https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT9smJ1wyUqfxLpdOKpmwn57nLlg6MCCtywlQ&usqp=CAU
Thank you!
The font can't be downloaded.
Example output:
Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
polygon edge not found
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Also, the Circular Air Light TTF font does not install correctly on MacOS. That is what the warnings are about.
Can we get a CRAN release of this? Requiring devtools to get this package is a big dependency.
Hi Ricardo - could you possibly advise what I'm doing wrong here?
require(ggplot2); require(ggradar); require(dplyr); require(tidyr)
dat = data.frame(month = rep(month.abb, 3) %>% factor(month.abb), group = rep(c('A','B','C'), each=12),
val = c(sample(11:22), sample(21:32), sample(31:42))) %>% spread(month, val)
dat
#> group Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
#> 1 A 11 20 15 21 17 19 13 14 12 18 22 16
#> 2 B 21 31 27 24 22 26 32 29 28 25 30 23
#> 3 C 32 36 40 31 35 42 33 37 39 41 34 38
ggradar(dat)
#> [1] "Error: 'plot.data' contains value(s) > grid.max"
I tried to install package ggradar but the installation seems to fail, (for windows ) and i´ve rtools
devtools::install_github("ricardo-bion/ggradar", dependencies = TRUE)
Downloading GitHub repo ricardo-bion/ggradar@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?
1: All
2: CRAN packages only
3: None
4: ellipsis (0.3.1 -> 0.3.2 ) [CRAN]
5: rlang (0.4.10 -> 0.4.11) [CRAN]
Enter one or more numbers, or an empty line to skip updates:
√ checking for file 'C:..\ricardo-bion-ggradar-63e5cef/DESCRIPTION' (489ms)
Installing package into ‘C:../R/win-library/4.0’
(as ‘lib’ is unspecified)
Hi Ricardo, thanks to your ggradar package, I am able to use radar chart to do data analysis. I found that more features can be added in the function, but it seems like that you have no time to maintain it. For the convenience reason, I have built a new package called 'ggradar2', which is based on your code. But some customizable features have been added and some syntax are adjusted to make code run in a right way. I am planning to add more features. So I am wondering if I may have your authorization to share the new package?
Is a fill function incorporated into your package? I am trying to fill the polygon with a color and transparency value and have not been able to find the syntax.
Thank you
I did some work on radars recently and used your package as one starting point to build my own package. That said, I was quite irritated by the 50% lines in your plot. They are not the 50% quantiles. They are just the middle between the maximum and the minimum values in your radar.
Don't know whether this problem belongs here - I'm new - but I would suggest to remove them or at least to remove them from the default option. Some hint in the documentation would also help.
I downloaded the zip file and tried to install the package ggradar as follows
library(devtools)
devtools::install("E:\\Programme\\r_pckg\\ggradar-master", type = "source")
This throws the following error
Error: Could not find package root.
How can I install the package from a local directory?
Hi, thanks for this package. It's pretty cool.
However, I notice that you hard-coded the font family in function ggradar
( family="Circular Air Light"
) without allowing users to assign their preferred font (correct me if I'm wrong), which is inconvenient for users (e.g., I want use a Chinese font).
Is there any specific reason that the family has to be hard-coded?
Thanks.
Hi when I run the example and try to save using pdf() or ggsave I have this error:
Error in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
invalid font type
In addition: There were 46 warnings (use warnings() to see them)
The warnings are:
1: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), ... :
font family 'Circular Air Light' not found in PostScript font database
Thank you for building such a wonderful tool for us. Recently I have a task to draw a radar chart and should put the actual value near the dots. Is there a way to implement it in ggradar? Or can I change some codes and add it by myself?
Thanks.
Error: 'plot.data' contains value(s) > grid.max
from tibble object with 13 rows and 12 columns?
Using the example from the readme:
> download.file("https://dl.dropboxusercontent.com/u/2364714/airbnb_ttf_fonts/Circular Air-Light 3.46.45 PM.ttf", "/Library/Fonts/Circular Air-Light 3.46.45 PM.ttf", method="curl")
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 216k 100 216k 0 0 491k 0 --:--:-- --:--:-- --:--:-- 491k
>
> extrafont::font_import(pattern = 'Circular', prompt=FALSE)
Scanning ttf files in /Library/Fonts/, /System/Library/Fonts, ~/Library/Fonts/ ...
Extracting .afm files from .ttf files...
/Library/Fonts/Circular Air-Light 3.46.45 PM.ttf => /Users/amos.elberg/Library/R/3.3/library/extrafontdb/metrics/Circular Air-Light 3.46.45 PM
Found FontName for 1 fonts.
Scanning afm files in /Users/amos.elberg/Library/R/3.3/library/extrafontdb/metrics
Writing font table in /Users/amos.elberg/Library/R/3.3/library/extrafontdb/fontmap/fonttable.csv
Writing Fontmap to /Users/amos.elberg/Library/R/3.3/library/extrafontdb/fontmap/Fontmap...
> library(ggradar)
>
> suppressPackageStartupMessages(library(dplyr))
> library(scales)
>
> mtcars %>%
+ add_rownames( var = "group" ) %>%
+ mutate_each(funs(rescale), -group) %>%
+ tail(4) %>% select(1:10) -> mtcars_radar
Warning message:
Deprecated, use tibble::rownames_to_column() instead.
>
> ggradar(mtcars_radar)
Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
polygon edge not found
Any suggestions?
Thanks for this package!
I am trying to produce a radar chart without a legend, but somehow the legend always shows up.
Example and result
library(ggplot2)
library(ggradar)
df <- data.frame(Name="Object_xx",Zustand=0.8, V1=0.5, V2=0.5, V3=0.5, V4=0.363)
r_chart <- ggradar(plot.data=df,
font.radar = "Helvetica",
grid.label.size = 4,
axis.label.size = 4,
plot.legend = T
)
plot(r_chart)
gives the following result:
However, what I want is this:
Hi, I really like your package, but I got this error:
ERROR: unable to collate and parse R files for package ‘ggradar’
when installing this package from github with devtools::install_github("ricardo-bion/ggradar", dependencies = TRUE)
Is there a workaround to the incompatibility with 3.5.1?
Is there an equivalent for facet_wrap?
I use ggradar
in combination with plotly
to create a radar chart. After using plotly
to obtain the hover-text ability I get the coordinates of every point when I mouse over each point but this does not make sense to me. How can I get the actual values instead of coordinates?
library(ggradar)
library(dplyr)
library(scales)
library(tibble)
library(plotly)
mtcars_radar <- mtcars %>%
as_tibble(rownames = "group") %>%
mutate_at(vars(-group), rescale) %>%
tail(4) %>%
select(1:10)
p<-ggradar(mtcars_radar)
ggplotly(p)
Hi Ricardo,
I've been trying to do a ggradar plot with some missing values, and the following error pops up:
Error in if (min(plot.data[, -1]) < centre.y) { :
missing value where TRUE/FALSE needed
The code which I've run is the following:
library(ggradar)
library(dplyr)
library(scales)
library(tibble)
datos=read.table(file = "Datos_SDM.csv", sep = ";", header = T, dec = ",")
head(datos)
data= datos[, c(2:13)]
head(data)
row.names(data)= c("2010", "2020", "2030", "2040", "2050")
data
data_radar= data%>%
as_tibble(rownames = "year")%>%
mutate_at(vars(-year), rescale, to= c(0, 10))%>%
select(1:6)
ggradar(data_radar, values.radar = c("0", "2", "4", "6", "8", "10"), grid.min = 0, grid.mid = 5, grid.max = 10)
Is it possible to do a ggradar plot with missing values? If so how should I do it?
Many thanks,
Javier
I have a data that looks like this with 10 rows
스 | ld | kt | ts | ss | ss1 | ss2 | ss3 |
---|---|---|---|---|---|---|---|
1 | 5 | 1 | 165 | 88 | 54 | 57 | 110 |
2 | 5 | 2 | 167 | 91 | 65 | 58 | 110 |
3 | 6 | 1 | 183 | 107 | 50 | 69 | 110 |
if I do following
data%>%filter(kt==1)%>%rename(group=스) %>% mutate_at(vars(-group),scales::rescale())
I get an error
Error: expecting a one sided formula, a function, or a function name.
If I don't do "scales::rescale()" I get an error saying
Error in check_dot_cols(.vars, .cols) : object 'rescale' not found
I've tried
data%>%filter(kt==1)%>%rename(group=스) %>% mutate_each(funs(rescale),-group)
and I get
Error in is_character(x) : object 'group' not found
can you help?
Why does ggradar not allow display of actual data values
Love the package - it's been a gamechanger for my work. Is there a way to set the label font to italics or bold? Looks like this can't be set in a theme as it appears that the label font is set with geom_text. I see that there is font.radar but that only allows changing the font family, not fontface.
Thank you!
David
Hi,
I would like to assign different linetypes for plotting two different sets of variables in ggradar. I tried something like
group.linetype = c("longdash", "solid")
or
group.line.type = c("longdash", "solid")
or
group.line.linetype = c("longdash", "solid")
None of the options work for me. What would be the right synthax to change that?
And another issue is that ggradar seems to order the variables automatically in an alphabetical order when plotting and putting together the legend. Can I change that default setting and keep the order of variables according to my dataset?
Many thanks for your great help!
Cheers
Susi
Thanks for this package!
I noticed when updating the Readme that when using all default arguments, the legend text size is now extremely small by default compared to the rest of the text. Looks like this is because base text size is 20 while default legend text size is 7. Of course users can update the legend text size but might be good to have better matching defaults.
Example and result below:
library(tibble)
mtcars %>%
rownames_to_column( var = "group" ) %>%
mutate_at(vars(-group),funs(rescale)) %>%
tail(4) %>% select(1:10) -> mtcars_radar
g <- ggradar(mtcars_radar)
fantastic work ! Helps me a lot for my projects.. However, is there a way to export in PDF? Any attempt leads to export in PDF leads to a white blank sheet.. Sorry, Im new here
Apologies if I missed the function, but I was wondering if it would be possible to plot error bars with ggradar, either (1) using a tibble with the grouping factor and the variables as columns, and one row per observation in each group, or (2) using a tibble with the grouping factor, the variables (means) and the error (standard deviations) as columns, and a single row per group.
The first way seems more straightforward, with maybe an argument in ggradar() to state what kind of error to calculate (using a fun=
), but the second way seems closer to the current way ggradar works (one row per group).
I love this package! Any chance you can add in a font color argument in the future? I see there's font.size, would be cool to add a font color to allows users to customize value labels and axis labels. Please let me know it exists and I've missed it in the documentation.
Hi, Ricardo.
I'm starting to use your package ggradar and I'm having a few problems:
Despite of that, it's a great package.
Renato
the base.size parameter is not functional. changing the value has no effect on text size in the ggradar chart
dat <- structure(list(tuition_and_fees_as_pct_total_rev_slope = 0.0116275839552173,
total_student_grants_as_pct_total_rev_slope = -0.0151290805847034,
govt_appropriations_grants_as_pct_total_rev_slope = 0.567182878972684,
sales_or_other_earned_revenue_as_pct_total_rev_slope = 0.168715061124856,
instruction_exp_as_pct_total_exp_slope = -0.265842023491547,
research_exp_as_pct_total_exp_slope = 0.256877374064898,
public_service_exp_as_pct_total_exp_slope = -0.260728569639251,
academic_support_as_pct_total_exp_slope = 0.0924740814929788,
student_service_as_pct_total_exp_slope = -0.038056463747445,
institutional_support_as_pct_total_exp_slope = -0.195679948781814,
total_debt_to_total_assets_ratio_slope = 0.164338557482071), row.names = c(NA,
-1L), class = c("tbl_df", "tbl", "data.frame"))
ggradar(dat)
# Error: plot.data' contains value(s) < centre.y
Can't use Circular Air-Light 3.46.45 PM.ttf font on Windows10 PC.
Used Microsoft Font Validator on this font.
Get the following error message:
"The file was not recognized as a valid OpenType font file".
Is there any way to use different scales on axes? Something similar to this question
Hi @ricardo-bion, I have a problem with rescaling... can you help me? I'm not so good in R, so maybe there's something I'm missing :)
genus <- read.delim("per_radar-chart.txt")
genus_radar <- genus %>%
mutate_each(funs(rescale), -Group) %>%
select(1:5) %>%
ggradar()
What I get is a fancy radar plot with only values 0 or 100%, not even a middle one... while my data file is:
Group Bacteroides Faecalibacterium Unclassified Ruminococcaceae Ruminococcus Escherichia Unclassified Clostridiales Akkermansia Unclassified Lachnospiraceae Roseburia Dialister Coprococcus Oscillospira Unclassified Rikenellaceae Veillonella Clostridium Streptococcus [Ruminococcus] Blautia SMB53 Parabacteroides Phascolarctobacterium Megamonas Citrobacter Lachnospiraceae (other)
HC 18.82899325 19.60617616 8.940147657 7.249336029 0.988030541 6.865308901 1.631560454 4.483545652 3.265902473 3.56638604 2.428487019 3.348809198 2.354368114 0.412104445 0.757058557 0.514498255 1.19583613 1.395051977 0.291326573 1.072784808 0.5056626 0.000374976 0.06799222 0.744098443
GSD 14.42678147 7.435798578 5.266405696 1.422892644 10.01335203 0.289875818 6.264758224 1.410419752 1.49970791 1.644507887 2.800174931 0.635045002 1.871660707 4.72936867 3.937134304 4.155349914 2.520429148 1.826753366 3.049466559 0.839257497 1.584002305 5.643196915 5.331207737 0.516412005
Can you help me? Thanks in advance!
I'm so excited to use this package to draw beautiful radar plot. And I found some limitation, I want to show the 20th, 40th, 60th and 80th lines or other value in the background, but this package can only set 0,0.5 and 1. So is there any way to fix this problem?
Hi, I am running the example code but got the error:
Error in FUN(X[[i]], ...) : object 'values.radar' not found
How can I resolve this?
Thanks
Hi Ricardo,
Thanks for this great library !
There is a little mistake at the end of the function though: you add + theme(legend.title = element_blank())
regardless of the legend.title
attribute.
Easy to workaround (just add + theme(legend.title = element_text())
to your ggradar
) but it should also be easy to correct.
Dan
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.