how to rotate histogram 90 degrees? and is it ok to use pylab with backends?

Hello, Was wondering if it is possible to rotate a histogram

    > 90 degrees? How do I do this?

Try replacing Axes.hist in site-packages/matplotlib/ with the
function below. You can call it with

  hist(randn(10000), 100, orientation='horizontal');

    > Also I want to change the labels and fontsize and things of
    > my tick labels. I'm using the backend WXAgg and I'm using
    > pylab.setp to set the tick attributes. Is this an ok thing
    > to do? I was under the impression that if I'm using a
    > backend like WXAgg that I want to stay away from pylab
    > because it has its own interface? Is this true? If it is
    > true is there something like setp for WXAgg? Thanks!!

Yes, this is true. Do not mix pylab with OO matplotlib. You can get
the setp function from matplotlib.artist, which is where pylab gets it from

  from matplotlib.artist import setp


    def hist(self, x, bins=10, normed=0, bottom=0,
             orientation='vertical', **kwargs):
        HIST(x, bins=10, normed=0, bottom=0, orientiation='vertical', **kwargs)

        Compute the histogram of x. bins is either an integer number of
        bins or a sequence giving the bins. x are the data to be binned.

        The return values is (n, bins, patches)

        If normed is true, the first element of the return tuple will be the
        counts normalized to form a probability distribtion, ie,

        orientation = 'horizontal' | 'vertical'. If horizontal, barh
        will be used and the "bottom" kwarg will be the left.

        kwargs are used to update the properties of the
        hist bars
        if not self._hold: self.cla()
        n,bins = matplotlib.mlab.hist(x, bins, normed)
        width = 0.9*(bins[1]-bins[0])
        if orientation=='horizontal':
            patches = self.barh(n, bins, height=width, left=bottom)
            patches =, n, width=width, bottom=bottom)
        for p in patches:
        return n, bins, silent_list('Patch', patches)

Hello, I'm using python 2.4 and matplotlib 0.83 with WXAgg. I'm having
trouble with plot dates and the datelocator. I want to show only 5 dates
tick labels because anymore than this then the labels get crunched
together. I can get this to work with the multiplelocator but not the
datelocator. I copied the function I call to manage all my plot
attributes below. I input the canvas figure, two axes instances (axesA,
and axesD) and a class called myAxes which holds attributes like label
size and font and colors and such. I am trying to do something like this
(this is part of the code copied below):

    elif myAxes.majorFormatName == 'Dates':
        min, max = Numeric.array(axesA.get_xlim())
        xFormat = DateFormatter('%m/%d/%y')
        xmajorLocator = DateLocator((max-min)/8.0)

    # set major x tick format
    # set major x tick format
    if myAxes.autoScale == False:
        # set major locator
        # set major locator

Notice I have to be aware of whether or not autoScale is being used. I
am not sure about this either. Can I set the locator and use auoscale? I
was having some errors occur when I tried to do this. The way it shows
above seems to solve that problem.

Does anyone know what might be the problem with the datelocator() as
I've done it?



# redraw figure attributes
def Plot_Figure_Attributes(figure, myAxes, axesD, axesA):
    # set where to tick
    # turn axes on or off
    if myAxes.ShowAxesFrame == True:
    # set range limits
    if myAxes.autoScale == False:
        axesA.set_xlim((myAxes.xRangeMin, myAxes.xRangeMax))
        axesD.set_xlim((myAxes.xRangeMin, myAxes.xRangeMax))
        axesA.set_ylim((myAxes.yRangeMinA, myAxes.yRangeMaxA))
        axesD.set_ylim((myAxes.yRangeMinD, myAxes.yRangeMaxD))
    # set figure background color

    # set figure face color
    # set legend
    if myAxes.legendShow == True:
        #get all instances of lines created by Plot()
        lines = axesA.get_lines()
    #create the legend
                'upper right')

    # set grid
    if myAxes.gridShow == True:
    if myAxes.yLabelShow == True:
        # set figure y label
        axesD.set_ylabel(myAxes.yLabelD, color=myAxes.yLabelColor,
size=myAxes.yLabelSize, rotation=myAxes.yLabelRot)
        # set figure y label
        axesA.set_ylabel(myAxes.yLabelA, color=myAxes.yLabelColor,
size=myAxes.yLabelSize, rotation=myAxes.yLabelRot)
    if myAxes.xLabelShow == True:
        # set figure x label
        axesD.set_xlabel(myAxes.xLabelD, color=myAxes.xLabelColor,
size=myAxes.xLabelSize, rotation=myAxes.xLabelRot)
    if myAxes.titleShow == True:
        # set figure title
        axesA.set_title(myAxes.title, color = myAxes.titleColor, size =

    (min, max) = axesA.get_ylim()
    # define major y tick locator
    ymajorLocator = MultipleLocator((max-min)/myAxes.yMajorTickLoc)
    # define minor y tick locator
    yminorLocator = MultipleLocator((max-min)/myAxes.yMinorTickLoc)
    # define major y tick format
    yFormat = FormatStrFormatter(myAxes.yLabelPrecision)
    # define minor x formats and locators
    if myAxes.majorFormatName == 'Multiples':
        (min, max) = axesA.get_xlim()
        if (max-min)/myAxes.xMinorTickLoc < 1:
            xmajorLocator = 1
            xmajorLocator = (max-min)/5.0
        xmajorLocator = MultipleLocator(xmajorLocator)
        xFormat = FormatStrFormatter('%d')
    elif myAxes.majorFormatName == 'Seconds':
        xmajorLocator = SecondLocator()
        xFormat = DateFormatter('%S')

    elif myAxes.majorFormatName == 'Dates':
        min, max = Numeric.array(axesA.get_xlim())
        xFormat = DateFormatter('%m/%d/%y')
        xmajorLocator = DateLocator((max-min)/8.0)
    elif myAxes.majorFormatName == 'Minutes':
        xmajorLocator = MinuteLocator()
        xFormat = DateFormatter('%M')
    elif myAxes.majorFormatName == 'Hours':
        xmajorLocator = HourLocator()
        xFormat = DateFormatter('%H')
    elif myAxes.majorFormatName == 'Days':
        xmajorLocator = DayLocator()
        xFormat = DateFormatter('%m/%d/%y')
    elif myAxes.majorFormatName == 'Months':
        xmajorLocator = MonthLocator()
        xFormat = DateFormatter('%m/%d/%y')
    elif myAxes.majorFormatName == 'Years':
        xmajorLocator = YearLocator()
        xFormat = DateFormatter('%m/%d/%y')

    # set major x tick format
    # set major x tick format
    if myAxes.autoScale == False:
        # set major locator
        # set major locator

    # set x and y tick labels attributes