axis-labels

Flip facet label and x axis with ggplot2

。_饼干妹妹 提交于 2019-11-28 11:29:45
I am looking to flip the labels on a faceted panel of 1 row and 5 columns, so that the facet headers appear on bottom, and the x axis appears on top of facets. The reason is that I want to reuse those headers for a table that will be directly below the graph. So in this example... library(ggplot2) my.hist<-ggplot(diamonds, aes(clarity)) + geom_bar() my.hist + facet_wrap( ~ cut, ncol=5) + coord_flip() I would want the "cut" labels to show up below the chart. I was thinking that facet_grid might hold the key, but is only a guess. Anyone know how to accomplish this? Getting the facet strips below

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

南楼画角 提交于 2019-11-28 08:43:48
问题 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:

Insert blanks into a vector for, e.g., minor tick labels in R

限于喜欢 提交于 2019-11-28 07:44:14
This question relates generally to a previous SO question concerning the creation of minor tick marks on a ggplot2 axis and specifically to a comment in the answer to that question suggesting a function to insert blanks into a sequence may prove useful. As I frequently add minor tick marks to similar plots, I took a stab at creating such a function (see my answer below). The following function allows the user to request that every n th element nth of a vector x either be (1) replaced with a empty character placeholder ( empty = TRUE ; default) or (2) omitted from the vector ( empty = FALSE ).

Superscript and subscript axis labels in ggplot2 [duplicate]

安稳与你 提交于 2019-11-28 03:58:22
This question already has an answer here: Subscript letters in ggplot axis label 2 answers I need an axis label in ggplot2 which reads "Assimilation (μmol CO2 m-2 s-1)" with the 2 of CO2 as subscript and the -2 and -1 as superscript. Thanks. You could try library(ggplot2) qplot(uptake, data = CO2) + xlab(bquote('Assimilation ('*mu~ 'mol' ~CO[2]~ m^-2~s^-1*')')) 来源: https://stackoverflow.com/questions/27445452/superscript-and-subscript-axis-labels-in-ggplot2

How to limit d3.svg.axis to integer labels?

爷,独闯天下 提交于 2019-11-28 02:24:56
问题 Is there any possibility to limit the number of d3.svg.axis integer labels displayed on the graph? Take for instance this graph. There are only 5 sizes here: [0, 1, 2, 3, 4] . However, the ticks are also displayed for .5, 1.5, 2.5 and 3.5 . 回答1: You should be able to use d3.format instead of writing your own format function for this. d3.svg.axis() .tickFormat(d3.format("d")); You can also use tickFormat on your scale which the axis will automatically use by default. 回答2: I've realised that it

Overlapping yticklabels: Is it possible to control cell size of heatmap in seaborn?

可紊 提交于 2019-11-28 01:18:05
I have a dataset with around 200 observations which I would like to plot as a heatmap. Each observation has a string associated with it which I would like to display. My problem is that I cannot read these labels since they overlap each other. My question is therefore, whether one can somehow set the cell size of the heatmap to the font size of the yticklabel or whether there is any other workaround for that. In my example below, I use random data for illustration purposes: import seaborn as sns import numpy as np data = np.random.rand(200, 10) ax = sns.heatmap(data) for item in ax.get

Scatter Plot 3D with labels and spheres

喜你入骨 提交于 2019-11-28 01:10:57
问题 I am trying to make a scatter plot with some data points (x,y,z,radius) and this is my result up to now: import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt x = np.random.rand(20) y = np.random.rand(20) z = np.random.rand(20) r = np.random.rand(20) plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble']=[r"\usepackage{amsmath}"] fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(x, y, z, s=np.pi*r**2*100, c='blue', alpha=0

matplotlib: adding padding/offset to polar plots tick labels

孤街浪徒 提交于 2019-11-27 22:59:40
Is there a way to increase the padding/offset of the polar plot tick labels (theta)? import matplotlib import numpy as np from matplotlib.pyplot import figure, show, grid # make a square figure fig = figure(figsize=(2, 2)) ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#d5de9c') ax.set_yticklabels([]) r = np.arange(0, 3.0, 0.01) theta = 2*np.pi*r ax.plot(theta, r, color='#ee8d18', lw=3) ax.set_rmax(2.0) show() I'd like to have theta tick labels further away from the polar plot so they don't overlap. First of all; seeing as how you have specified the figsize to be (2,2) and having

Curve Fitting to a time series in the format 'datetime'?

浪子不回头ぞ 提交于 2019-11-27 22:57:12
Here is my problem: polyfit does not take datetime values, so that I converted datetime with mktime producing the polynomial fit works z4 = polyfit(d, y, 3) p4 = poly1d(z4) For the plot however, I would like the datetime description on the axis and didn't # figure out how to do that. Can you help me? fig = plt.figure(1) cx= fig.add_subplot(111) xx = linspace(0, d[3], 100) pylab.plot(d, y, '+', xx, p4(xx),'-g') cx.plot(d, y,'+', color= 'b', label='blub') plt.errorbar(d, y, yerr, marker='.', color='k', ecolor='b', markerfacecolor='b', label="series 1", capsize=0, linestyle='') cx.grid() cx.set

Mathematical expression in axis label

有些话、适合烂在心里 提交于 2019-11-27 22:07:04
问题 In R, I use expression(theta[l]) so that the label of my plot axis is that same as $\theta_l$ from LaTeX. For esthetic reasons, I'd rather like to display $\theta_\ell$ . Can you help me? EDIT Before, I did plot(1:10, 1:10, xlab=expression(theta[l])) and I exported the resulting picture in pdf. Then, using \begin{figure}[htbp] \centerline{\includegraphics[scale=.6]{test.pdf}} \end{figure} my picture was inserted in LaTeX. Following the comments, here is what I now do: require(tikzDevice) tikz