bar-chart

matplotlib: change timestamp format of x-grid in a bar-chart

痴心易碎 提交于 2019-12-11 03:15:11
问题 I have the following code: my_df.plot(x='my_timestamp', y='data_count', kind='bar') and the output looks like this: I am wondering is it possible to change the x-grid format, so it will just show 2016-03-14 instead of 2016-03-14 00:00:00 Thanks! 回答1: There might be a more elegant solution, but what definitely works is to loop over the xticklabels, split them up and only use the first part of the string as a new ticklabel. ax = df.plot(x='my_timestamp', y='data_count', kind='bar') ax.set

Using JSON in d3v4 stacked bar chart

我们两清 提交于 2019-12-11 02:57:39
问题 I have found a d3v3 stacked bar chart example that I would like to use because it uses json data. There is also a d3v4 canonical bar chart example that loads and uses a csv. I want to make a d3v4 stacked bar chart but I want to use json data to create it rather than load from a csv. I am not sure how to upgrade the v3 version or to modify the v4 version to accomplish this. This is my data structure: [{ "hospitalName": "hospital1", "category": "Injury & Poisoning", "Females": "0", "Males": "4"

Calculate and plot 95% confidence interval for a given dataframe

 ̄綄美尐妖づ 提交于 2019-12-11 02:55:18
问题 How do I plot a bar plot from a data frame and a 95% confidence interval in the same graph using matplotlib on python(using the yerr arguement if possible). The plot should look like: The dataframe looks like this with 3649 entries: 回答1: Try this: import pandas as pd import matplotlib.pyplot as plt from scipy import stats mean = df.mean(axis = 1) std = df.std(axis = 1) n= df.shape[1] yerr = std / np.sqrt(n) * stats.t.ppf(1-0.05/2, n - 1) plt.figure() plt.bar(range(df.shape[0]), mean, yerr =

Setting X-axis label in d3.js

元气小坏坏 提交于 2019-12-11 02:27:37
问题 In my d3.js bar chart i want the X-axis labels to be in "vertical". I'm getting the labels in "Horizontal" but the problem is some of the labels getting merged. <!DOCTYPE html> <style> body { font: 10px sans-serif; } .axis path, .axis line { fill: none; stroke: #000; shape-rendering: crispEdges; } .bar { fill: red; } .x.axis path { display: none; } </style> <body> <script src="http://d3js.org/d3.v3.min.js"></script> <script> var margin = {top: 20, right: 20, bottom: 30, left: 40}, width = 960

How to apply solid colors to data bar in Excel VBA?

◇◆丶佛笑我妖孽 提交于 2019-12-11 02:19:26
问题 My data bar looks good (solid) when executing the VBA command. However, after I saved the file and reopened, data bar changed to gradient automatically. How do I avoid this? Before saving and reopening file: After saving and reopening file: Here's the code I used: Dim DB As Databar Set DB = Range("K2:K10").FormatConditions.AddDatabar With DB .BarFillType = xlDataBarSolid .BarBorder.Type = xlDataBarBorderSolid With .BarBorder.Color .Color = 15698432 End With With .BarColor .Color = 15698432

Gnuplot: Bar chart from a function

青春壹個敷衍的年華 提交于 2019-12-11 01:31:47
问题 In difference to nearly 99.9% of all Gnuplot bar chart examples I don't have a data file but a function I want to visualize as a bar chart. Let us take for example take the simple function f(x) = x I want a bar char that creates one bar for every value of x between 0 and 20 (step size 1). Therefore I used the following code, but it does not create 20 bars - it creates a lot more (about 100?). set xtic 1 set xrange [0:20] set boxwidth 1 set style fill solid f(x)=x plot f(x) with boxes How to

How to move the values displayed on the bar to down to it?

…衆ロ難τιáo~ 提交于 2019-12-11 01:08:44
问题 Currently working with stack bar chart in jqplot. My doubt is how to move the value displayed on the bar to down of its bar? fiddle avail at here $(document).ready(function(){ var yAxisLabels = ["Label1", "Label2", "Label3", "Label4"]; var legendValues = ["series1", "series2", "series3", "series4"]; var pLabels1 = ['70%','38%','71%','28%']; var pLabels2 = ['27%','49%','27%','44%']; var pLabels3 = ['2%','10%','2%','17%']; var pLabels4 = ['1%','4%','1%','12%']; var group4 = [52,528,129,264];

How to create a stacked barchart using d3?

核能气质少年 提交于 2019-12-11 00:54:57
问题 I have an object array: var data = [ {"ORDER": 1, "apples": 3840, "bananas": 1920, "cherries": 960}, {"ORDER": 2, "apples": 1600, "bananas": 1440, "cherries": 960}, {"ORDER": 3, "apples": 640, "bananas": 960, "cherries": 640}, {"ORDER": 4, "apples": 320, "bananas": 480, "cherries": 640} ]; I want to create a stacked bar chart so that the orders are on the x axis and the total of apples, bananas, and cherries are the y axis. Here is my code so far: x = d3.scaleOrdinal().range([0, w-50]) y = d3

NVD3 Logarithmic Y axis with barchart

≡放荡痞女 提交于 2019-12-10 23:14:36
问题 I have a barchart made with NVD3 that shows datas with a huge gap between min value and max value. This makes the chart not really nice/usefull. Example : Y value are between 4,000 and 60,000 then some value are near 3m. I would like to have an Y Axis value increasing logarithmically, that show something like this (see the y Axis) : I tried to change yAxis scale, yAxis Domain, but didn't find any working solution (FYI: I use nvd3 through angularJs directives) 回答1: This will work for you chart

How to organize error bars to relevant bars in a stacked bar plot in ggplot?

北战南征 提交于 2019-12-10 22:14:28
问题 I stacked the bar plots from three different treatment together for comparison. However, I am having trouble putting the error bars in the right position. I am not sure if my codes are correct since I have a feeling that this should be an easy fix. Any help would be appreciated. dff <- structure(list(month = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L), .Label = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"), class = c("ordered", "factor")