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

  • Home
  • SEARCH
  • 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 6187651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:05:45+00:00 2026-05-24T02:05:45+00:00

I wrote the code below to output the figure but still need to figure

  • 0

I wrote the code below to output the figure but still need to figure out two things.

1) How do I get scientific notation on the axis for the minor tick label. Since I only have it show the 5000 I assume I could just change this in the showOnlySomeTicks function to return a string in scientific format. Is there a better way to do this?? Also a better way to show only the 5000 minor tick mark (eg 5e5).
2) I want to make the minor tick mark label size smaller than the major tick mark label size. How do I go about this?

Cheers for any help

import matplotlib.pyplot as plt
import matplotlib.ticker as tick
from numpy import load, sqrt, shape, size

def clear_spines(ax):
    ax.spines['top'].set_color('none')
    ax.spines['right'].set_color('none')
def set_spineLineWidth(ax, lineWidth):
    for i in ax.spines.keys():
        ax.spines[i].set_linewidth(lineWidth)
def showOnlySomeTicks(x, pos):
    s = str(int(x))
    if x == 5000:
        return s
    return ''


plt.close('all')
spineLineWidth = 0.5
inFile = '7semiat220'
outFile = inFile
inExt = '.npz'
outExt = ['.eps','.pdf','.tif','.png']
mydpi = 300
storeMat = load(inFile+inExt)
fig_width_pt = 246.0  
inches_per_pt = 1.0/72.27               
golden_mean = (sqrt(5)-1.0)/2.0         
fig_width = fig_width_pt*inches_per_pt  
fig_height = 2 #fig_width*golden_mean       
fig_size = [fig_width,fig_height]
tick_size = 9
fontlabel_size = 10.5
params = {'backend': 'wxAgg', 'axes.labelsize': fontlabel_size, 'text.fontsize': fontlabel_size, 'legend.fontsize': fontlabel_size, 'xtick.labelsize': tick_size, 'ytick.labelsize': tick_size, 'text.usetex': True, 'figure.figsize': fig_size}
plt.rcParams.update(params)
x = storeMat['freq']
y = storeMat['mag']
sizeX = x.size
fig = plt.figure(1)
#figure(num=None, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
#fig.set_size_inches(fig_size)
plt.clf()
ax = plt.axes([0.125,0.2,0.95-0.125,0.95-0.2])
plt.plot(x,y,'k',label='$\sin(x)$')
plt.xscale('log')
plt.xlim(x[sizeX-1]*.95,x[0]*1.05)
plt.xlabel('Log Frequency (Hz)')
plt.ylabel('Magnitude')
set_spineLineWidth(ax,spineLineWidth)
clear_spines(ax)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
ax.xaxis.set_minor_formatter(tick.FuncFormatter(showOnlySomeTicks))
#plt.legend()
for i in outExt:
    plt.savefig(outFile+i, dpi = mydpi)
#def grayConvert()
#Image.open('color.png').convert('L').save('bw.png') #direct method
#image=Image.open('colored_image.png').convert("L") #other manipulations can use this method
#arr=np.asarray(image)
#p.figimage(arr,cmap=cm.Greys_r)
#p.savefig('grayed.png')

output

  • 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-24T02:05:46+00:00Added an answer on May 24, 2026 at 2:05 am

    You have to use a combination of Formatter and Locator

    The locator will tell where the tick should be placed.

    The Formatter will return the string to be displayed at the location.

    see: Ticker module documentation

    ax.xaxis.set_minor_locator( xLocator )
    ax.xaxis.set_minor_formatter( xminorFormatter )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the below xml code, I need to get b1 and b2 as my
I wrote the code below : 1. MyClass[] origArr=new MyClass[3]; 2. MyClass[] arr1; 3.
I wrote the code below to split up a fullname from a .csv file
I have wrote below code. import java.io.*; class Test { public static void main(String
I wrote a program today and I need to show percentage in my output
I wrote in my noteBook the code below and I write it now in
When I run my code below I get a: ValueError: invalid literal for int()
The code I wrote is as below : #!/usr/bin/perl my @input = ( a.txt
I wrote the below code in order to check for three files and whichever
I wrote some code which monitors the output of Stopwatch using a tight loop.

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.