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 8611923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:29:51+00:00 2026-06-12T04:29:51+00:00

I have a scatter plot with logarithmic x- and y axis (because I’m mainly

  • 0

I have a scatter plot with logarithmic x- and y axis (because I’m mainly interested in the lower values along both).

However, I want the tick labels to be in decimal format, not as 10^x.

I’m using this:

# axis limits:
ax.set_xlim(xmin=0, xmax = 1.2)
ax.set_ylim(ymin=0,ymax=1000)

# log scales:
ax.set_yscale('log')
ax.set_xscale('log')

# set y-ticks:
ax.set_yticks((1,10,100,1000))
ax.set_yticklabels(("1","10","100","1000"))

This works (though introducing ax.set_yscale('log') or ax.set_xscale('log') brings up the following warning (any idea what’s up with that?):

Warning (from warnings module):
  File "C:\Python27\lib\site-packages\numpy\ma\core.py", line 3785
warnings.warn("Warning: converting a masked element to nan.")
UserWarning: Warning: converting a masked element to nan.

But when I try the same for the x-axis, I get a MaskError:

# set x-ticks:
ax.set_xticks((0, 0.2, 0.4, 0.8, 1))
ax.set_xticklabels(("0", "0.2", "0.4", "0.8", "1"))

[snip long long traceback]
File "C:\Python27\lib\site-packages\numpy\ma\core.py", line 3795, in __int__
  raise MaskError, 'Cannot convert masked element to a Python int.'
MaskError: Cannot convert masked element to a Python int.

I think it has something to do with minor vs major ticks. I have tried to play around with ticker, but always run into the same error in the end.

I’d be immensely grateful for any help!

Edit after answer:
Problem solved by replacing

ax.set_yticks((1,10,100,1000))
ax.set_yticklabels(("1","10","100","1000"))
ax.set_xticks((0, 0.2, 0.4, 0.8, 1))
ax.set_xticklabels(("0", "0.2", "0.4", "0.8", "1"))

with

ax.yaxis.set_major_formatter(FormatStrFormatter('%1.0f'))
ax.xaxis.set_major_formatter(FormatStrFormatter('%.1f'))
ax.xaxis.set_minor_formatter(FormatStrFormatter('%.1f'))
  • 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-06-12T04:29:52+00:00Added an answer on June 12, 2026 at 4:29 am

    You can use ticker as:

    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib.ticker import FormatStrFormatter
    
    fig = plt.figure(1, [5,4])
    ax = fig.add_subplot(111)
    
    ax.plot( range(1,100) , range(1,100) ,  color='#aaaaff')
    ax.set_xscale('log')
    ax.xaxis.set_major_formatter(FormatStrFormatter('%.03f'))
    plt.show()
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scatter-plot with many values on a polar axis - coord_polar() .
I have a simple scatter plot x<-rnorm(100) y<-rnorm(100) z<-rnorm(100) I want to plot the
I have an x-y scatter plot in MATLAB and want to put a data
I have function which performs scatter plot and I want to paste the results(Jpeg
I have a 2-D scatter plot and at the origin I want to display
I'm looking to a scatter plot with a rotated X axis. Basically, I want
I have a scatter plot in R (with ggplot2). The data has a numeric
I have a scatter plot with 10 points, some points are above and below
I want to create a scatter plot with regression line, while using size aesthetics
i have a scatter plot graph i would like each dot to have a

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.