axis-labels

Detect when matplotlib tick labels overlap

一世执手 提交于 2021-02-05 07:06:30
问题 I have a matplotlib bar chart generated by pandas, like this: index = ["Label 1", "Label 2", "Lorem ipsum dolor sit amet", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis ac vehicula leo, vitae sodales orci."] df = pd.DataFrame([1, 2, 3, 4], columns=["Value"], index=index) df.plot(kind="bar", rot=0) As you can see, with 0 rotation, the xtick labels overlap. How can I detect when two labels overlap, and rotate just those two labels to 90 degrees? 回答1: There is no easy way to

How to color ticktext in plotly?

只愿长相守 提交于 2021-02-04 19:15:26
问题 I would like to display my ticktexts in my plotly xaxis with different colors based on the respective string (based on a dictionary). Is there a functionality in plotly to do this, maybe via HTML coding? ticktext = ['<font color="red">{}</font> '.format(x) for x in ticktexts] doesn't work, it gives the html string to the labels. 回答1: A little bit of a workaround using LaTeX can help you here (sorry @Iwileczek, I stole your example, hope you don't mind) because plotly has full LaTeX support:

How to color ticktext in plotly?

末鹿安然 提交于 2021-02-04 19:15:13
问题 I would like to display my ticktexts in my plotly xaxis with different colors based on the respective string (based on a dictionary). Is there a functionality in plotly to do this, maybe via HTML coding? ticktext = ['<font color="red">{}</font> '.format(x) for x in ticktexts] doesn't work, it gives the html string to the labels. 回答1: A little bit of a workaround using LaTeX can help you here (sorry @Iwileczek, I stole your example, hope you don't mind) because plotly has full LaTeX support:

Need to add legend and fix axis in ggplot [duplicate]

六月ゝ 毕业季﹏ 提交于 2021-01-29 17:22:04
问题 This question already has answers here : Add legend to ggplot2 line plot (3 answers) Closed 22 days ago . I'm new to ggplot and I'm trying to figure out how to add a legend to a graph and re-label the x-axis. I've enclosed the plotting code and resulting graph . I would like to add a legend that explains what the blue line and the green and red dots are. I would also like the years on the x-axis to appear as 2018, 2019, ... , 2020 instead of 2017.5, 2010.0, ..., 2020.0. I can't find a

Uneven axis in base r plot

浪尽此生 提交于 2021-01-29 13:00:30
问题 I want to have a plot the axes of which be similar to attached images. I am particularly interested in the X axis of the attachment. Generally, an axis that shows for example 0 to 10. My data are located somewhere like 5-7 of the x axis. So I want my 25% x axis to show 0-5 and the rest 75% to show 5-10 . But I do not mean something like ggpplot. I am working with base R. and the image is also created with R base, i guess. How should I make a plot like the example? Thank you Thank you for your

AmCharts v4 linechart, starts dateaxis 1 month late

橙三吉。 提交于 2021-01-27 20:04:58
问题 Using amcharts 4 i am displaying an xy chart (simple line graph). Each datapoint has the data set in chart.data, the first as and the following with 1 week intervals: { "Date": new Date(2015, 12, 31), "Value: 12345, "LineColor: "#000000" }, { "Date": new Date(2016, 01, 07), "Value: 234567, "LineColor: "#000000" } Despite this, the first dateAxis point displayed on the chart is (after formatting) Sun 31 Jan 2016 , which is not among the dates input. If i change the dateAxis.baseInterval to

How to add labels to a boxplot figure (pylab)

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-27 06:26:01
问题 This is a pretty basic question I'm sure but I cannot seem to find the right code. There is my code for the boxplot I am creating. I would like to label the axes and have a title. from pylab import * import numpy raw_data = list(numpy.genfromtxt(filename, delimiter=',')) print raw_data figure() boxplot(raw_data,1) savefig('testfigure.pdf') I have tried pylab.xlabel('x') and plt.xlable('x') but those do not work...? Do they not work for boxplots or have I just got it wrong about those lines

How to add labels to a boxplot figure (pylab)

只谈情不闲聊 提交于 2021-01-27 06:25:29
问题 This is a pretty basic question I'm sure but I cannot seem to find the right code. There is my code for the boxplot I am creating. I would like to label the axes and have a title. from pylab import * import numpy raw_data = list(numpy.genfromtxt(filename, delimiter=',')) print raw_data figure() boxplot(raw_data,1) savefig('testfigure.pdf') I have tried pylab.xlabel('x') and plt.xlable('x') but those do not work...? Do they not work for boxplots or have I just got it wrong about those lines

Overlapping letters in tics and labels gnuplot 5.4

喜夏-厌秋 提交于 2021-01-01 06:49:07
问题 I have recently updated my gnuplot to the latest 5.4. I find problems with the labels and tics using the pngcairo terminal. For example, taking a simplified example from the official website set terminal pngcairo enhanced font "arial,20" fontscale 1.0 size 600, 400 set output 'pm3d6.png' set pm3d map splot sin(sqrt(x**2+y**2))/sqrt(x**2+y**2) I get a figure that looks fine, but letters in the labels and tics overlap in a strange way. Any idea about why this happens? 回答1: Very likely a known

Modifying plot title and Y axis label when plotting acf & ccf

a 夏天 提交于 2020-12-26 16:49:37
问题 I have the following cross correlation function (ccf) with an acf class which I am trying to plot: > data.ccf<-structure(list(acf = structure(c(0.00370070496127902, 0.00206467231169963, 0.0225750357110768, 0.00298746518949757, 0.0145032913293758, 0.00963688419028638, 0.0333911509122289, 0.0339875564324283, 0.0250934925494934, 0.000676008442887869, 0.00492135501146539, -0.00592692854683653, -0.0107895022365464, 0.00609386610167392, -0.00984595563932813, -0.0171226578533912, -0.0293648412902752