axis-labels

How to display all label values in matplotlib?

☆樱花仙子☆ 提交于 2019-11-30 11:13:28
I have two lists, when I plot with the following code, the x axis only shows up to 12 (max is 15). May I know how can I show all of the values in x list to the x axis? Thanks in advance. x = [4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3] y = [10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160] fig = plt.figure() ax1 = fig.add_subplot(111) ax1.plot(np.arange(len(x)), y, 'o') ax1.set_xticklabels(x) plt.show() If I set minor=True in the set_xticklabels function, it shows me all x=2,4,6,8,..,16... but I want ALL values. P.S. My x axis is not sorted, should display as it shows. Add this: ax1.set

Matplotlib: Add strings as custom x-ticks but also keep existing (numeric) tick labels? Alternatives to matplotlib.pyplot.annotate?

£可爱£侵袭症+ 提交于 2019-11-30 08:16:53
I am trying to produce a graph and I am having some issues annotating it. My graph has a log scale on the x-axis, showing time. What I want to be able to do is keep the existing (but not predictable) numeric tick labels at 100 units, 1000 units, 10000 units, etc but also add custom tick labels to the x-axis that make it clear where more "human readable" time intervals occur---for instance I want to be able to label 'one week', 'one month', '6 months', etc. I can use matplotlib.pyplot.annotate() to mark the points but it doesn't really do what I want. I don't really want text and arrows on top

Multiple y-axis conversion scales

一笑奈何 提交于 2019-11-30 07:42:16
Hi I'm trying to create plots which incorporate parallel conversion scales for two sets of units on the y-axis; using the two different styles of: offset ('parasitic') y-axes and overlaid/shared y-axes to replicate the style of the left-hand y-axes in the attached example images. I'd like to find the simplest generic way of producing both of the above example plots, which also allows me to generate the y-axis conversion scales by defining the relationship between the two sets of units as a function (in this example: mmHg = kPa * 7.5). If it's possible to add the third right-hand y axes (vapour

Format latitude and longitude axis labels in ggplot

隐身守侯 提交于 2019-11-30 05:14:18
I have a ggplot map, for example: library(ggmap) ggmap(get_map()) I'd like the axis labels to be automatically labeled as N-S / W-E: in the above case, for example, instead of lon -95.4 it should show 95.4°E. I have tried to mess with the scales package and using scale_x_continuous and scale_y_continuous labels and breaks options, but I have not managed to make it work. It would be awesome to have a scale_y_latitude and scale_x_longitude . EDIT: Thanks to @Jaap 's answer I got to the following: scale_x_longitude <- function(xmin=-180, xmax=180, step=1, ...) { ewbrks <- seq(xmin,xmax,step)

HTML in Chart.js labels

落爺英雄遲暮 提交于 2019-11-30 04:10:04
问题 I'd like to put some images and/or links in my chart's labels. Here's the example code and jsFiddle: var data = { labels: ['January', '<s>February</s>', '<img src="http://jsfiddle.net/favicon.png">', '<a href="http://jsfiddle.net/">A Link</a>'], datasets: [{ data: [65, 59, 90, 81] }] } var ctx = document.getElementById("myChart").getContext("2d"); var myNewChart = new Chart(ctx).Bar(data); jsFiddle link As you can see, the HTML is not parsed inside labels. Is there a way to have working

r boxplot tilted labels x axis

大城市里の小女人 提交于 2019-11-30 03:30:42
问题 how can you rotate the labels of the x axis for boxplot in r? I know which code to use but I can't apply it: text(**????**, par("usr")[3] - 0.25, srt = 45, adj = 1, labels = labels, xpd = TRUE) What variable goes where I have the question marks? I created this boxplot: using this code: soil=read.csv("soil_temp_boxplot.csv", header=TRUE, sep=";") tiff("soil_boxplot.tiff") par(mar=c(5.5,3.5,0.5,0.5)) labels<-paste(c("RB-GL830-[16]-10","RB-GL830-[16]-30", "SB-GL834-[11]-10","SB-GL834-[11]-30",

Thousand separator in label of x or y axis

﹥>﹥吖頭↗ 提交于 2019-11-29 16:24:30
问题 I would like to have pretty labels on the y-axis. For example, I prefer to have 1,000 instead of 1000. How can I perform this in ggplot? Here is a minimum example: x <- data.frame(a=c("a","b","c","d"), b=c(300,1000,2000,4000)) ggplot(x,aes(x=a, y=b))+ geom_point(size=4) Thanks for any hint. 回答1: With the scales packages, some formatting options become available: comma, dollar, percent. See the examples in ?scale_y_continuous . I think this does what you want: library(ggplot2) library(scales)

ggplot2 x - y axis intersect while keeping axis labels

痞子三分冷 提交于 2019-11-29 16:14:54
I posted my original question yesterday which got solved perfectly here Original post I made a few addition to my code library(lubridate) library(ggplot2) library(grid) ### Set up dummy data. dayVec <- seq(ymd('2016-01-01'), ymd('2016-01-10'), by = '1 day') dayCount <- length(dayVec) dayValVec1 <- c(0,-0.22,0.15,0.3,0.4,0.10,0.17,0.22,0.50,0.89) dayValVec2 <- c(0,0.2,-0.17,0.6,0.16,0.41,0.55,0.80,0.90,1.00) dayValVec3 <- dayValVec2 dayDF <- data.frame(Date = rep(dayVec, 3), DataType = factor(c(rep('A', dayCount), rep('B', dayCount), rep('C', dayCount))), Value = c(dayValVec1, dayValVec2,

barplot x-axis labels with hierarchical grouping variables in separate rows

我只是一个虾纸丫 提交于 2019-11-29 14:39:17
In Excel, with data organized like so: Bare NP Singular-Marked NP Plural-Marked NP BrP Speakers AmE Speakers BrP Speakers AmE Speakers BrP Speakers AmE Speakers Plural Interpretation 0.005747126 0.006896552 0.194117647 0.124567474 0.872093023 0.985815603 Plural & Singular Interpretation 0.649425287 0.910344828 0.029411765 0.051903114 0.127906977 0.014184397 Singular Interpretation 0.344827586 0.082758621 0.776470588 0.823529412 0 0 I am able to produce a stacked barchart that looks like this: Is there an easy way to reproduce the way that the x-axis is partitioned into the separate conditions

Changing the radius of a coord_polar ggplot

為{幸葍}努か 提交于 2019-11-29 10:41:32
I'm looking to reduce the display radius of a pie chart built in ggplot2 relative to the rest of the plot (as the defaults keep cutting off my category labels). Here's some dummy data and code that should show you what I'm experiencing: library(ggplot2) library(scales) library(grid) Region <- c("North America", "Central America", "South America", "Carribbean", "Western Africa", "Northern Africa", "Southern Afica", "Eastern Africa") Conti <- c(rep("Americas",4), rep("Africa",4)) Freq <- c(runif(8, 1, 100)) Pct <- c(Freq/sum(Freq)) Pos <- c(cumsum(360*Pct)-(360*Pct/2)) Pos <- c(ifelse(Pos<=180