axis-labels

Matplotlib: show labels for minor ticks also

烂漫一生 提交于 2019-12-17 18:57:41
问题 In matplotlib , when I use a log scale on one axis, it might happen that that axis will have no major ticks , only minor ones. So this means no labels are shown for the whole axis. How can I specify that I need labels also for minor ticks? I tried: plt.setp(ax.get_xticklabels(minor=True), visible=True) ... but it didn't do the trick. 回答1: I've tried many ways to get minor ticks working properly in log plots. If you are fine with showing the log of the value of the tick you can use matplotlib

Matplotlib: show labels for minor ticks also

橙三吉。 提交于 2019-12-17 18:57:04
问题 In matplotlib , when I use a log scale on one axis, it might happen that that axis will have no major ticks , only minor ones. So this means no labels are shown for the whole axis. How can I specify that I need labels also for minor ticks? I tried: plt.setp(ax.get_xticklabels(minor=True), visible=True) ... but it didn't do the trick. 回答1: I've tried many ways to get minor ticks working properly in log plots. If you are fine with showing the log of the value of the tick you can use matplotlib

d3.js: Align text labels between ticks on the axis

无人久伴 提交于 2019-12-17 17:41:44
问题 Is there an easy way to align text labels between ticks? Here is my time axis with labels above the ticks: I would like to place these labels like here: 回答1: I ended up with one of the Lars Kotthoff's advices. Every time when I call(axis) I also adjust text labels. Here is simplified code: function renderAxis() { axisContainer .transition().duration(300) .call(axis) // draw the standart d3 axis .call(adjustTextLabels); // adjusts text labels on the axis } function adjustTextLabels(selection)

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

柔情痞子 提交于 2019-12-17 12:25:55
问题 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='.',

How to insert two X axis in a Matlab a plot

萝らか妹 提交于 2019-12-17 10:59:58
问题 I would like create a Matlab figure with a double X axis (m/s and km/h) with the same plot. I have found plotyy and - in Matlab reposity - plotyyy, but I am looking for: A double X axis. Together below the plot. My code is very simple: stem(M(:, 1) .* 3.6, M(:, 3)); grid on xlabel('Speed (km/h)'); ylabel('Samples'); M(:, 1) is the speed (in m/s), and M(:, 3) is the data. I would like only a second line, in the bottom, with the speeds in m/s. 回答1: You can do something like the following. In

Second Y-Axis in a R plotly graph

做~自己de王妃 提交于 2019-12-14 04:18:24
问题 I combined 2 charts and I am trying to add the second y-axis, but every time I add the yaxis = "y2" to my code, I lose have the my bar graphs. > MediaDate Spend Search_Visits Other_Visits MediaDate2 > 2016-04-01 $39654.36 19970 2899 Apr 2016 > 2016-05-01 $34446.28 14460 2658 May 2016 > 2016-06-01 $27402.36 12419 2608 Jun 2016 my original code is: p <- plot_ly(x= w$MediaDate2,y=w$Search_Visits,name = "Paid Search", type = "bar") p2 <- add_trace(p, x=w$MediaDate2, y=w$Other_Visits,name = "Other

Python subplots leaving space for common axis labels

陌路散爱 提交于 2019-12-14 01:35:56
问题 I have the following code that makes four subplots in one figure: f = figure( figsize=(7,7) ) f.add_axes([0.2,0.175,0.75,0.75]) f.subplots_adjust(left=0.15) f.clf() ax = f.add_subplot(111) ax1 = f.add_subplot(221) ax2 = f.add_subplot(222) ax3 = f.add_subplot(223) ax4 = f.add_subplot(224) ax.xaxis.set_major_formatter( NullFormatter() ) ax.yaxis.set_major_formatter( NullFormatter() ) ax2.xaxis.set_major_formatter( NullFormatter() ) ax2.yaxis.set_major_formatter( NullFormatter() ) ax1.xaxis.set

Negative axis in a log plot

我的未来我决定 提交于 2019-12-13 16:24:11
问题 I'm plotting a log plot using matplotlib. My values go from 1 to 35. fig=plt.figure(figsize=(7,7)) fig.subplots_adjust(top=0.75, right=0.9) ax=fig.add_subplot(111) ax.plot(x, y, marker='o', color='black', ls='') ax.set_xscale('log') ax.set_yscale('log') I would like to set the x- and y-axis starting from values lower than 1, but if I use ax.axis([-10,45,-10,45]) it doesn't work. I know that it is because I'm using a log scale, but is there a way to solve the problem obtaining the axis I want?

gnuplot: fill area curve keeping tics on top

久未见 提交于 2019-12-13 12:28:57
问题 in gnuplot, when you try to fill an area under a curve, the tics of both axes are hinded behind the solid area. Is there any way to give them to the front? I am using postcript terminal, where no transparent features are allowed (i guess) Thanks 回答1: There sure is! Before plotting, run this interactively or in a script: set tics front Try help tics interactively for more info. 回答2: After trying many options I realized that the following works properly: set tics front It seems important to

Several colors for the same tick/label

心已入冬 提交于 2019-12-13 11:36:12
问题 My data : dat <- data.frame(x = c(1,2,3,4,5,6), y = c(2,3,4,6,2,3)) Breaks and labels of my plot : breaks <- c(3,5) labels <- c(paste(3,"(0.3)"), paste(5,"(0.5)")) And my plot : library(ggplot2) ggplot() + geom_point(data = dat, aes(x = x, y = y)) + scale_y_continuous(breaks = breaks, labels = labels) I wish to colour the same labels differently. For instance, I wish to colour the "3" with a different colour than the one of "(0.3)". 回答1: Here's a way to stick 2 plots together with patchwork ,