data-visualization

Annotate Deleted my previous Formatting in plt

梦想与她 提交于 2019-12-14 04:07:16
问题 I am using Matplotlib.pyplot library in order to draw a barchart of a dataframe.I am using the code below and i am using the scripting layer instead of using the artist layer(object oriented method). I have solve my problem with the artist layer however i want to solve it with the plt method as well. PROBLEM:Firsty I format the plot and then I want to put percentages in the top of each barchart ,however when I do the annotation method to put the percentages the previous formatting is

2d plot with 3rd variable as color in RStudio

*爱你&永不变心* 提交于 2019-12-13 22:58:54
问题 I have a dataset as CSV with three columns: timestamp (e.g. 2018/12/15) keyword (e.g. "hello") count (e.g. 7) I want one plot where all the lines of the same keyword are connected with each other and timestamp is on the X- and count is on the Y- axis. I would like each keyword to have a different color for its line and the line being labeled with the keyword. The CSV has only ~30.000 rows and R runs on a dedicated machine. Performance can be ignored. I tried various approaches with mathplot

ggplot2: Reversing the order of discrete categories on y-axis in scatterplot [duplicate]

元气小坏坏 提交于 2019-12-13 22:03:51
问题 This question already has an answer here : how to reverse order y-axis values in ggplot2 (1 answer) Closed 4 years ago . I'm stuck trying to figure out how to revise this code so that in the scatterplot Architecture is on the top of the Y-axis and Visual Arts is on the bottom of the Y-axis. UPDATE: With respect to the "duplicate" misclassification - My point was if there was an elegant way to do this WITHIN ggplot2, not simply reordering the levels in the data frame. ggplot() + geom_point(aes

Creating 100% stacked area graph for a website

断了今生、忘了曾经 提交于 2019-12-13 20:06:35
问题 I am trying to add a chart to my website showing how income earned is divided between two parties. It is essentially the 100% stacked graph in excel that would look something like: Is there a good (ideally inexpensive, since the only one I've found that might do it is Highcharts, which looks great but it's not cheap for what we are doing) tool that we could embed into our website? Ideally it would be great if the user could select a certain price and it would show the percentage below for the

d3js updates only once

拜拜、爱过 提交于 2019-12-13 19:18:05
问题 I have a visualization task that I need to make it done with d3.js. Here's my code. var w = 700; var h = 500; var offset = 100; var padding = 20; var colors = d3.scale.category10(); var svg = d3.select("body") .append("svg") .attr("width", w) .attr("height", h); var texts = function(ds,ds2){ var stack = d3.layout.stack(); stack_data = stack(ds); var xScale = d3.scale.ordinal() .domain(d3.range(ds[0].length)) .rangeRoundBands([0, w-offset], 0.50); var yScale = d3.scale.linear() .domain([0, d3

Rectangle with a bottom arc cut in d3 js

烂漫一生 提交于 2019-12-13 14:44:25
问题 I was able to get only the rectangle. Not able to figure out how to produce the cut in the bottom? define(['jquery', 'knockout', 'd3', 'data/server', 'css!app/css/vista'],function($, ko, d3, server){ return { activate: function(){ }, compositionComplete: function(){ var self = this; self.loadyourRank(); }, loadyourRank: function(){ var data = [3]; var width = 325, height = 430; var svgContainer = d3.select("#yourrank") .append("svg") .attr("width", width) .attr("height", height); svgContainer

Double header in Matplotlib Table

送分小仙女□ 提交于 2019-12-13 13:12:34
问题 I need to plot a table in matplotlib. The problem is some columns have one-level headers, some columns have double-level headers. Here's what I need: Here's simple example for one-level headers: df = pd.DataFrame() df['Animal'] = ['Cow', 'Bear'] df['Weight'] = [250, 450] df['Favorite'] = ['Grass', 'Honey'] df['Least Favorite'] = ['Meat', 'Leaves'] df fig = plt.figure(figsize=(9,2)) ax=plt.subplot(111) ax.axis('off') table = ax.table(cellText=df.values, colColours=['grey']*df.shape[1], bbox=[0

ggplot2 : How to reduce the width AND the space between bars with geom_bar

馋奶兔 提交于 2019-12-13 12:14:33
问题 I understand that one can change the width of a bar in geom_bar using the width argument. That does work, but then it creates a larger gap between the bars. Is there a way to manually push the bars closer to together? Should I be manipulating the axis somehow instead? Here is an example, changing width to 0.3 on the right to get the desired bar width. library(tidyverse) library(gridExtra) p1 <- ggplot(iris, aes(Species, Petal.Length)) + geom_bar(stat="summary") p2 <- ggplot(iris, aes(Species,

Automating great-circle map production in R

大兔子大兔子 提交于 2019-12-13 12:04:20
问题 I've taken some of the things I learned in a Flowing Data great circle mapping tutorial and combined them with code linked in the comments to prevent weird things from happening when R plots trans-equatorial great circles. That gives me this: airports <- read.csv("/home/geoff/Desktop/DissertationData/airports.csv", header=TRUE) flights <- read.csv("/home/geoff/Desktop/DissertationData/ATL.csv", header=TRUE, as.is=TRUE) library(maps) library(geosphere) checkDateLine <- function(l){ n<-0 k<

Bar charts connected by lines / How to connect two graphs arranged with grid.arrange in R / ggplot2

烂漫一生 提交于 2019-12-13 11:49:53
问题 At Facebook research, I found these beautiful bar charts which are connected by lines to indicate rank changes: https://research.fb.com/do-jobs-run-in-families/ I would like to create them using ggplot2. The bar-chart-part was easy: library(ggplot2) library(ggpubr) state1 <- data.frame(state=c(rep("ALABAMA",3), rep("CALIFORNIA",3)), value=c(61,94,27,10,30,77), type=rep(c("state","local","fed"),2), cumSum=c(rep(182,3), rep(117,3))) state2 <- data.frame(state=c(rep("ALABAMA",3), rep("CALIFORNIA