axis-labels

matplotlib: histogram and bin labels

寵の児 提交于 2019-12-04 02:38:12
I'm trying to plot a histogram with bar chart, and I'm having difficulties figuring out how to align the x-axis labels with the actual bins. The code below generates the following plot: as you can see, the end of each x-label is not aligned to the center of its bin. The way i'm thinking about this is: when i apply a 45-degree rotation, the label pivots around its geometrical center. I was wondering if it's possible to move the pivot up to the top of the label. (Or simply translate all the labels slightly left.) import matplotlib.pyplot as plt import numpy as np #data np.random.seed(42) data =

WstxUnexpectedCharException: Unexpected character '\"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers

六眼飞鱼酱① 提交于 2019-12-04 02:34:29
I am trying to solve the below issue for last couple of days but still not able to resolve it. I have searched lots of forums but all in vain. * Little bit of history: My code was working well in the devp env but for accessing the production sever I received new URL and three new certificates after successfully including the certificates in new trust store file.I am facing below issue. Please help. 2013-11-25 11:32:30,373 INFO[BuilderUtil] OMException in getSOAPBuilder org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE

Custom ggplot2 axis and label formatting

让人想犯罪 __ 提交于 2019-12-04 01:17:40
I'm trying to draw labels which look informative, clear and tidy. I was following example and raised one more question about label and axis formatting. For example, I have sales data which includes Brand, Categories and Expenditure in EUR. When sum of EUR is big (millions or more) labels look really hard to read and not informative. As a result, x-axis is in Scientific notation and also looks really uncleanly. I've manage to format labels in custom way: it shows Eur in thousands. geom_text(aes(label= paste(round(EUR/1000,0),"€"), y=pos), colour="white") Is there an easier or automated way? As

Custom y-axis scale and secondary y-axis labels in ggplot2 3.1.0

a 夏天 提交于 2019-12-04 00:26:28
Edit 2 The current developmental version of the ggplot2-package does solve the bug mentioned in my question below. Install the dev version using devtools::install_github("tidyverse/ggplot2") Edit It seems as the faulty behaviour of sec_axis in ggplot2 3.1.0 is a bug. This has been recognized by the devs and they are working on a fix (see thread on GitHub). Goal I have a graphic where the y-axis ranges from 0 to 1. I'd like to add a secondary y-axis that ranges from 0 to 0.5 (so exactly half the values of the primary y-axis). So far no problem. What complicates the matter is that I have a

matplotlib set xticks to column, labels to corresponding index

橙三吉。 提交于 2019-12-03 22:28:41
问题 I am pretty new to matlpotlib and I find the tick locators and labels confusing, so please bear with me. I swear I've been googling for hours. I have a dataframe 'frame' like this (relevant columns): dayofweek sla weekday Mon 1 0.889734 Tue 2 0.895131 Wed 3 0.879747 Thu 4 0.935000 Fri 5 0.967742 Sat 6 0.852941 Sun 7 1.000000 where the weekday name is the index and the weekday number is a column. There are no datetime objects in this frame. I turn this into a plt.figure fig=plt.figure(figsize=

Avoiding axis tick label collision in faceted ggplots

穿精又带淫゛_ 提交于 2019-12-03 17:02:15
问题 In multi-panel/faceted plots, I like when it's feasible to squash the panels together with no space between them, e.g. using theme(panel.spacing=grid::unit(0,"lines")) (Edward Tufte says this is good because the inter-panel spaces produce distracting visual effects, as well as wasting data-space, and I've drunk this particular bit of the Kool-Aid.) The problem is that, depending on the precise range of the values within a row/column of facets, the axis labels for neighboring facets can

How can you create a box around an axis tick label in ggplot2?

江枫思渺然 提交于 2019-12-03 11:21:35
问题 For several reasons, I am trying to duplicate the grotesque plot shown below. It violates many precepts of good data visualization so for training purposes my goal is to use ggplot2 and deconstruct it -- remove or revise poorly-chosen features one at a time. Using the data reproduced at the bottom and the code below the plot, I am getting close but have been unable to figure out how to include one notable feature. Question: Is there a way to reproduce the black shaded rectangle around the

Increasing Frequency of x-axis labels for dates on DataFrame plot

北城以北 提交于 2019-12-03 10:13:37
I have a pandas DataFrame with two columns: month_of_sale which is a date, and number_of_gizmos_sold which is a number. I'm trying to increase the frequency of the labels on the x-axis so it's easier to read, but I can't! Here is the df.head() of my table: and this is what it plots: df.plot(y='number_of_gizmos_sold', figsize=(15,5)) I'd like to increase the frequency of the labels, because there's a big space in between them. What I've tried plot.xaxis.set_major_locator(MonthLocator()) but that seems to increase the distance between the labels even more. plot.xaxis.set_major_formatter

matplotlib: draw major tick labels under minor labels

梦想的初衷 提交于 2019-12-03 09:45:20
问题 This seems like it should be easy - but I can't see how to do it: I have a plot with time on the X-axis. I want to set two sets of ticks, minor ticks showing the hour of the day and major ticks showing the day/month. So I do this: # set date ticks to something sensible: xax = ax.get_xaxis() xax.set_major_locator(dates.DayLocator()) xax.set_major_formatter(dates.DateFormatter('%d/%b')) xax.set_minor_locator(dates.HourLocator(byhour=range(0,24,3))) xax.set_minor_formatter(dates.DateFormatter('

Avoiding axis tick label collision in faceted ggplots

依然范特西╮ 提交于 2019-12-03 05:59:47
In multi-panel/faceted plots, I like when it's feasible to squash the panels together with no space between them, e.g. using theme(panel.spacing=grid::unit(0,"lines")) (Edward Tufte says this is good because the inter-panel spaces produce distracting visual effects, as well as wasting data-space, and I've drunk this particular bit of the Kool-Aid.) The problem is that, depending on the precise range of the values within a row/column of facets, the axis labels for neighboring facets can overlap. For example, in this plot there's a collision between the bottom tick label in the top panel and the