axis-labels

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

北战南征 提交于 2019-11-29 09:02:55
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 . 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. I've realised that it is enough to hide these values, rather than to completely exclude. This can be done using the tickFormat (https:

Scatter Plot 3D with labels and spheres

点点圈 提交于 2019-11-29 07:26:08
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.75) ax.set_xlabel(r'$x$ $\left[\frac{\text{Mpc}}{h}\right]$') ax.set_ylabel(r'$y$ $\left[\frac{\text{Mpc

Mathematical expression in axis label

此生再无相见时 提交于 2019-11-29 03:12:48
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("test.tex", standAlone=TRUE, width=5, height=5) plot(1:10, 1:10, xlab="$\\theta_\\ell$") dev.off()

Python: How to increase/reduce the fontsize of x and y tick labels?

淺唱寂寞╮ 提交于 2019-11-29 02:59:07
问题 I seem to have a problem in figuring out how to increase or decrease the fontsize of both the x and y tick labels while using matplotlib . I am aware that there is the set_xticklabels(labels, fontdict=None, minor=False, **kwargs) function, but I failed to understand how to control the fontsize in it. I expected something somehow explicit, like title_string=('My Title') plt.suptitle(title_string, y=1.0, fontsize=17) but I haven't found anything like that so far. What am I missing? 回答1: One

Format latitude and longitude axis labels in ggplot

会有一股神秘感。 提交于 2019-11-29 02:54:02
问题 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

matplotlib: Aligning y-axis labels in stacked scatter plots

和自甴很熟 提交于 2019-11-29 02:28:35
问题 In the plot bellow i have two scatter plots which have different number scale, so their Y-axis labels are not aligned. Is there any way I can force the horizontal alignment in the y-axis labels? import matplotlib.pylab as plt import random import matplotlib.gridspec as gridspec random.seed(20) data1 = [random.random() for i in range(10)] data2 = [random.random()*1000 for i in range(10)] gs = gridspec.GridSpec(2,1) fig = plt.figure() ax = fig.add_subplot(gs[0]) ax.plot(data1) ax.set_ylabel(r

Change the color of the axis labels

瘦欲@ 提交于 2019-11-28 21:24:13
Here's the relevant code: ggplot.3plus<-ggplot(summary.3plus, aes(x=sp1, y=fract.mean, fill=ForestAge)) + geom_bar(position=position_dodge())+ coord_cartesian(ylim = c(1, 1.175))+ geom_errorbar(aes(ymin=fract.mean-se, ymax=fract.mean+se), width=.2, # Width of the error bars position=position_dodge(.9)) ggplot.3plus<- ggplot.3plus + theme(axis.title.x = element_text(colour = "red")) You can see that with the last line of code, I can change the color of the axis title, but not the color of the axis LABELS. What about ggplot.3plus + theme(axis.text.x=element_text(colour="red")) See ggplot2 wiki

Matplotlib - hiding specific ticks on x-axis

白昼怎懂夜的黑 提交于 2019-11-28 20:26:52
I am trying to hide the first and last x-axis tick text of my bar plot, which is '2004' and '2013'. Matplotlib automatically adds these in by default, even though my dataset is for 2005 to 2012, hence I'd prefer not to have 2004 and 2013 in my bar plot. I'm looking for some lines of code to select and hide these ticks. Any ideas? Please, tell me if it's not what you want. import sys, os import matplotlib.pyplot as plt path = sys.path[0] sizes = [(12,3,), (4,3,)] x = range(20) for i, size in enumerate(sizes): fig = plt.figure(figsize = size, dpi = 80, facecolor='white',edgecolor=None,linewidth

d3 axis labeling

Deadly 提交于 2019-11-28 15:56:24
How do I add text labels to axes in d3? For instance, I have a simple line graph with an x and y axis. On my x-axis, I have ticks from 1 to 10. I want the word "days" to appear underneath it so people know the x axis is counting days. Similarly, on the y-axis, I have the numbers 1-10 as ticks, and I want the words "sandwiches eaten" to appear sideways. Is there a simple way to do this? Axis labels aren't built-in to D3's axis component , but you can add labels yourself simply by adding an SVG text element. A good example of this is my recreation of Gapminder’s animated bubble chart, The Wealth

Remove plot axis values

前提是你 提交于 2019-11-28 15:40:54
I was just wondering if there is a way to get rid of axis values, either the x-axis or y-axis respectively, in an r-plot graph. I know that axes = false will get rid of the entire axis, but I would only like to get rid of the numbering. Remove numbering on x-axis or y-axis: plot(1:10, xaxt='n') plot(1:10, yaxt='n') If you want to remove the labels as well: plot(1:10, xaxt='n', ann=FALSE) plot(1:10, yaxt='n', ann=FALSE) Using base graphics, the standard way to do this is to use axes=FALSE, then create your own axes using Axis (or axis). For example, x <- 1:20 y <- runif(20) plot(x, y, axes