On Wed, Feb 8, 2012 at 8:42 AM, David Craig <dcdavem...@gmail.com> wrote:

Hi, I have a plot of a time series and I would like to add a single
> extra tick mark and label to the plot in a different color to the
> already existing tick marks. Is this possible??
> Thanks,
>


It's fairly easy to do if you want to set the tick locations and labels
youself (see http://matplotlib.sourceforge.net/users/artists.html near the
end for an overview of the mpl containers like Tick and the attributes they
contain).

    import matplotlib.pyplot as plt
    import numpy as np

    fig, ax = plt.subplots(1)

    ax.plot(np.random.randn(10,2)*10)

    locs = np.arange(2, 10, 2)
    labels = ['%d'%loc for loc in locs]
    ticks, labels = plt.xticks(locs, labels)

    i = 2
    # tick1line and tick2line are matplotlib.lines.Line2D instances
    ticks[i].tick1line.set_color('red')
    ticks[i].tick2line.set_color('red')
    labels[i].set_color('red')

    plt.show()

If you want to "add a tick" using the existing mpl auto tick locating and
labeling infrastructure, it is also possible but you will need to subclass
the tick locator.



JDH
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to