Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One way to do it is to use the minor ticks. The idea is that you set the minor ticks so that they are located halfway between the major ticks, and you manually specify the labels.</p> <p>For example:</p> <pre><code>import matplotlib.ticker as ticker # a is an axes object, e.g. from figure.get_axes() # Hide major tick labels a.xaxis.set_major_formatter(ticker.NullFormatter()) # Customize minor tick labels a.xaxis.set_minor_locator(ticker.FixedLocator([1.5,2.5,3.5,4.5,5.5])) a.xaxis.set_minor_formatter(ticker.FixedFormatter(['1','2','3','4','5'])) </code></pre> <p>The three lines:</p> <ul> <li>"Hide" the 1,2,3,4,... that you have on the major ticks</li> <li>Set minor ticks halfway between the major ticks (assuming your major ticks are at 1,2,3...)</li> <li>Manually specifies the labels for the minor ticks. Here, '1' would be between 1.0 and 2.0 on the graph.</li> </ul> <p>This is just a simple example. You would probably want to streamline it a bit by populating the lists in a loop or something.</p> <p>You can also experiment with other <a href="http://matplotlib.org/api/ticker_api.html" rel="noreferrer">locators or formatters</a>.</p> <p><strong>Edit:</strong> Alternatively, as suggested in the comments:</p> <pre><code># Hide major tick labels a.set_xticklabels('') # Customize minor tick labels a.set_xticks([1.5,2.5,3.5,4.5,5.5], minor=True) a.set_xticklabels(['1','2','3','4','5'], minor=True) </code></pre> <hr> <h3>Example:</h3> <p><strong>Before:</strong> <img src="https://i.stack.imgur.com/LoiF5.png" alt="Before"></p> <p><strong>After:</strong> <img src="https://i.stack.imgur.com/vNWuD.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload