zmeers / ggparliament Goto Github PK
View Code? Open in Web Editor NEWSimple parliament plots using ggplot2
Home Page: https://zmeers.github.io/ggparliament/
License: Other
Simple parliament plots using ggplot2
Home Page: https://zmeers.github.io/ggparliament/
License: Other
parliament_data giving this error. Everything seems to be working so I assume its a case of just going through the code and removing this. Will leave it for the immediate future as it isn't breaking anything
Hi Rob,
Is this package still being actively maintained? If not, would you be interested in handing the package off or adding co-ownership to the repository?
Thanks,
Zoe
It would be nice to include d3-parliament in the package so users can create interactive parliament plots with minimal work on their end.
wayyyy back when we started this I don't think there was actually a coalition in Germany so I can't remember why I went with what I did.
Anyway, for the 2017 election it should be the CDU and the SDP in government
"bar"
"pie"
"rose"
"waffle"
We tentatively plan to submit to CRAN on the 20th of August, with a firm deadline for the end of August.
Dear all,
is it possible to create a plot which sorts the parliamentary parties by their ideological orientation, e.g. from far left to far right. This should be an important issue, because this type of parliamentary visualization is very common in Political Science and journalism.
Thanks in advance!
I'll create a PR for scale_colour_party()
once the repository has been transferred to Rob's account.
Write a quick chunk to show how to make plots from a data frame that is created in situ. Shouldn't be too fancy- something akin to Thomas' former stuff on the old README.
hi
I have been trying to plot this kind of seat diagram for a long time. Thank you for such a powerful tool. It works well.
I have a confusion though. It seems to me that the order of parties in the graph is the same, or has to be the same as the order in the data, d
or d2
. As you did in your examples, Party
in d
is a factor
, but the labels
seems not work.
My codes are like this:
d <- data.frame(Party = factor(c("V","S","MP","KD","C","FP","M","SD","NYD"),
levels = c("V","S","MP","KD","C","FP","M","SD","NYD")),
Number = c(21,113,25,16,22,19,84,47,2))
party.color.scale.color <- scale_color_manual(values = c("V" = "#b00000",
"S" = "#EE2020",
"MP" = "#80AA4E",
"SD" = "#fedf09",
"NYD" = "grey50",
"C" = "#39944A",
"FP" = "#0069b4",
"KD" = "#2D338E",
"M" = "#52bcec"),
breaks = c("V","S","MP","KD","C","FP","M","SD","NYD"))
p <- ggparliament(d
,party = Party
,seats1 = Number
,style = "dots"
,label = "both"
,size = 4
,nrows = 10
,total = 6
)
p <- p + theme_void() + theme(legend.title = element_blank())
p <- p + party.color.scale.color
p
Both color and seat number is correct. That was done by manually sorting the parties in d
. Also, when I chose label = "both"
, the party names and seat number are mismatched.
Any suggestion how I can improve this?
Thanks again.
We should fix these and resubmit to CRAN. I also need to update the citation for the package, so I'll create a PR
It's possible to make solid filling instead of points? How? Thanks a lot for this library!
See title - pretty self-explanatory, I thin.
I am attempting to build an R app that pulls election data from my SQL database and creates visualizations using the ggparliament package. I have built in methods for filtering the data to one house-country-year dataframe, which has all of the necessary variables for running the parliament_data() function. However, when I attempt to run my dataframe through this function, I get the "Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 0, 435" message, which prevents me from successfully creating the dataframe needed to create the plot. I have tried dozens of different iterations, removing all extraneous columns and NA values, but for some reason I cannot seem to get past this issue.
This is a screenshot of the dataframe I am attempting to pass through the function. I have even tried formatting the column names and order to be identical to the examples, but the error persists.
Please let me know if anyone else has had a similar problem, or if there is a workaround I have not tried yet. Some of the code and the data are proprietary for my work so I cannot share everything but happy to provide some additional information if needed. Thank you!
I think this occurs because the type call in the aes isn't actually mapped to data. Aesthetics transform the data and type does not... It's really there so we don't have to specify type in the additional calls later on. I'm not really sure what to do here... Either we keep it as it is even though it's not really correct or we go back to defining the type in draw_majoritythreshold()
and draw_partylabels()
Just chatted with my advisor and I spoke with Thomas ~1 month ago about writing an academic paper for ggparliament
.
Places we can think about submitting to:
I'm happy to do most (all?) of the legwork for this if you're not interested, @RobWHickman. Just throwing the idea out there. I'm not sure if you're interested in doing more academic work.
I have just run through the updated 'ggparliament' version on GitHub (v2.1.0) and get the following error when running the example for Australia:
"Error: Unknown colour name: #F00011"
I have compared the data with the Cran version (v 2.0.0) and it appears to be the same but runs ok with no errors.
All the other countries. work. ok with the latest GitHub version , just not with the data for Australia.
cheers
M
I think we should consider breaking down ggparliament()
into separate geoms.
This will give the user more flexibility over the final product and it should more like an extension to ggplot2 instead of a separate plotting system.
Moreover, breaking the monolithic functions into separate geoms gives us the opportunity to create additional functions for data preparation and scales for party colours.
The user will have the ability to pick and choose separate parts of the package AND they won't have to learn entirely new parameters as the ggplot2 syntax should be relatively familiar to them already. I'm proposing that we do the following (they are just examples and I'm open to change!):
geom_parliament_dots(aes(x=x,y=y,group=group), type=c('u-shape', 'hemicircle', 'bench'), ...)
geom_parliament_waffle()
geom_parliament_rose()
geom_parliament_arc()
geom_parliament_bar()
parliament_data(transform=c('dots', 'waffle', 'rose', 'arc', 'bar')
scale_colour_party(country="Australia")
scale_fill_party()
Thomas is moving into industry (congrats!) so needs new maintainers for packages
see: https://twitter.com/thosjleeper/status/994135461550534656
Add data for german Bundestag elections in 2021.
https://www.bundestag.de/parlament/plenum/sitzverteilung_20wp
Notes:
2 Non-attached members, one is sitting next to "Bündnis 90 / Die Grünen" the other one came with AfD but left after the elections.
Is it possible to put them on the right place?
I tried running this package on Indian General Elections. I copied the code from documentation and used Indian political parties data as input by changing necessary code. But I keep getting error like given below.
Warning message:
Removed 435 rows containing missing values (geom_point)
I made my data similar to election_data dataset but didn't get any success.
Then I copied the original code from package documentation and ran the code on us parliament data with election_data dataset. But issue remained same even with original code and original data. Even chart is not proper.
If I remove scale color manual limits argument then chart comes but still not proper. Please help.
Also attaching Indian elections data for reference.
I also tried putting same fields as in election_data data set
for Indian elections data, but without success.
ss.xlsx
The .rda data in /data is a bit unclean- especially ward_results.
Here's a list of things to do (non-exhaustive)
(might be by design) the classroom parliaments look to me like the need to be flipped 90degrees to make a bit more sense?
Currently the largest party is on the right, but I assume the largest party at the front makes the most sense?
Hmm, I'm curious to see if this will work. Say someone has a long list of every MP in parliament with their party affiliation, i.e. column 1 is name and column 2 is party....
Can we still use parliament_data() to find the x and y coordinates, providing they specify the row numbers and type? It might be something to look into and in theory should be easy to implement (famous last words, right?!) as the data doesn't need to expand, we just need to map the x and y coordinates to each parliamentarian.
Provided the user writes seats = NULL, or even seats = "long_format" in parliament_data(), we could then say if (object$seats == NULL / "long_format") { calc_coordinates ... } .
For example...
data <- data.frame(
name <- c(...),
party <- c(...)
)
seats <- parliament_data(type = 'semicircle',
parl_rows = 8,
seats = "long_format",
election_data = data)
This should spit out the same data frame plus x, y, row, theta -- basically everything we get from calc_coordinates anyway. The user can then add whatever additional data they want, like colours, gender, etc.
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.