Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6097083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:00:07+00:00 2026-05-23T13:00:07+00:00

I am trying to create a plot but I just want the ticklabels to

  • 0

I am trying to create a plot but I just want the ticklabels to show as shown where the log scale is shown as above. I only want the minor ticklabel for 50, 500 and 2000 to show. Is there anyway to specify the minor tick labels to show?? I have been trying to figure this out for a bit but haven’t found a good solution. All I can think of is to get the minorticklabels() and set the fontsize to 0. This is shown below the first snippet of code. I was hoping there was a more clean solution.

The other thing is changing the size of the ticklabels in the colorbar which I haven’t figured out. If anyone knows of a way to do this please let me know because I don’t see a method in colorbar that easily does this.

First code:

fig = figure(figto)
ax = fig.add_subplot(111)
actShape = activationTrace.shape
semitones = arange(actShape[1])
freqArray = arange(actShape[0])
X,Y = meshgrid(self.testFreqArray,self.testFreqArray)
Z = sum(activationTrace[:,:,beg:end],axis=2)
surf = ax.contourf(X,Y,Z, 8, cmap=cm.jet)
ax.set_position([0.12,0.15,.8,.8])
ax.set_ylabel('Log Frequency (Hz)')
ax.set_xlabel('Log Frequency (Hz)')
ax.set_xscale('log')
ax.set_yscale('log')
ax.xaxis.set_minor_formatter(FormatStrFormatter('%d'))
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
ax.tick_params(axis='both',reset=False,which='both',length=8,width=2)
self.plotSetAxisLabels(ax,22)
self.plotSetAxisTickLabels(ax,18)
cbar = fig.colorbar(surf, shrink=0.5, aspect=20, fraction=.12,pad=.02)
cbar.set_label('Activation',size=18)
return ax, cbar

enter image description here

Second Code:

fig = figure(figto)
ax = fig.add_subplot(111)
actShape = activationTrace.shape
semitones = arange(actShape[1])
freqArray = arange(actShape[0])
X,Y = meshgrid(self.testFreqArray,self.testFreqArray)
Z = sum(activationTrace[:,:,beg:end],axis=2)
surf = ax.contourf(X,Y,Z, 8, cmap=cm.jet)
ax.set_position([0.12,0.15,.8,.8])
ax.set_ylabel('Log Frequency (Hz)')
ax.set_xlabel('Log Frequency (Hz)')
ax.set_xscale('log')
ax.set_yscale('log')
ax.xaxis.set_minor_formatter(FormatStrFormatter('%d'))
ax.yaxis.set_minor_formatter(FormatStrFormatter('%d'))
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
ax.tick_params(axis='both',reset=False,which='both',length=8,width=2)
self.plotSetAxisLabels(ax,22)
self.plotSetAxisTickLabels(ax,18)
cbar = fig.colorbar(surf, shrink=0.5, aspect=20, fraction=.12,pad=.02)
cbar.set_label('Activation',size=18)
count = 0
for i in ax.xaxis.get_minorticklabels():
    if (count%4 == 0):
        i.set_fontsize(12)
    else:
        i.set_fontsize(0)
    count+=1
for i in ax.yaxis.get_minorticklabels():
    if (count%4 == 0):
        i.set_fontsize(12)
    else:
        i.set_fontsize(0)
    count+=1
return ax, cbar

enter image description here

For the colorbar:
Another quick question if you don’t mind because trying to figure it out but not entirely sure. I want to use scientific notation which I can get with ScalarFormatter. How do I set the number of decimal places and the multiplier?? I’d like it to be like 8×10^8 or .8×10^9 to save space instead of putting all those zeros. I figure there is multiple ways to do this inside the axes object but what do you reckon is the best way. I can’t figure out how to change the notation when changing to the ScalarFormatter.

For the chart:
Also, my data has points starting at 46 and then at successive multiplies of that multiplied by 2^(1/12) so 46,49,50,55,58,61…3132. These are all rounded but lie close to the 2^(1/12). I decided it better to place major tickers close to these numbers. Is the best way to use the fixed formatter and use a ticker every 15 or so in the freqArray. Then use a minor ticker at every other frequency. Can I do this and still maintain a log axis??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:00:07+00:00Added an answer on May 23, 2026 at 1:00 pm
    1. Use FixedLocator to statically define explicit tick locations.
    2. Colorbar cbar will have an .ax attribute that will provide access to the usual axis methods including tick formatting. This is not a reference to an axes (e.g. ax1, ax2, etc.).
    import numpy as np
    import matplotlib.pyplot as plt
    
    fig = plt.figure()
    ax = fig.add_subplot(111)
    x = np.arange(10,3000,100)
    y = np.arange(10,3000,100)
    X,Y = np.meshgrid(x,y)
    Z = np.random.random(X.shape)*8000000
    surf = ax.contourf(X,Y,Z, 8, cmap=plt.cm.jet)
    ax.set_ylabel('Log Frequency (Hz)')
    ax.set_xlabel('Log Frequency (Hz)')
    ax.set_xscale('log')
    ax.set_yscale('log')
    ax.xaxis.set_minor_formatter(plt.FormatStrFormatter('%d'))
    # defining custom minor tick locations:
    ax.xaxis.set_minor_locator(plt.FixedLocator([50,500,2000]))
    ax.yaxis.set_ticks_position('left')
    ax.xaxis.set_ticks_position('bottom')
    ax.tick_params(axis='both',reset=False,which='both',length=8,width=2)
    cbar = fig.colorbar(surf, shrink=0.5, aspect=20, fraction=.12,pad=.02)
    cbar.set_label('Activation',size=18)
    # access to cbar tick labels:
    cbar.ax.tick_params(labelsize=5) 
    plt.show()
    

    enter image description here

    Edit

    If you want the tick marls, but you want to selectively show the labels, I see nothing wrong with your iteration, except I might use set_visible instead of making the fontsize zero.

    You might enjoy finer control using a FuncFormatter where you can use the value or position of the tick to decide whether it gets shown:

    def show_only_some(x, pos):
        s = str(int(x))
        if s[0] in ('2','5'):
            return s
        return ''
    
    ax.xaxis.set_minor_formatter(plt.FuncFormatter(show_only_some))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create a user account in a test. But getting a Object reference
I am trying to create plot some push pins on map using GeoCoordinate as
I'm trying to create a ggplot2 plot with the legend beneath the plot. The
I am trying to create a Google Map where the user can plot the
I am trying to create a simple scatter plot with PlotSymbols for when I
I am trying to create a filled contour plot in matplotlib (Win7, 1.1.0). I
I am trying to create a 3D plot in Matlab. I have a very
I am trying to use ggplot2 to create a boxplot graph but I am
I'm trying to create a pdf of a TukeyHSD post hoc test plot (through
As question, I am trying to create a plot using the following code: chart.demo.sex.age

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.