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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:02:21+00:00 2026-05-28T17:02:21+00:00

I have a matplotlib horizontal bar drawn as follows: import matplotlib.pyplot as plt from

  • 0

I have a matplotlib horizontal bar drawn as follows:

import matplotlib.pyplot as plt
from numpy import *
from scipy import *
bars = arange(5) + 0.1
vals = rand(5)
print bars, vals
plt.figure(figsize=(5,5), dpi=100)
spines = ["bottom"]
ax = plt.subplot(1, 1, 1)
for loc, spine in ax.spines.iteritems():
  if loc not in spines:
    spine.set_color('none')
# don't draw ytick marks
#ax.yaxis.set_tick_params(size=0)
ax.xaxis.set_ticks_position('bottom')
plt.barh(bars, vals, align="center")
plt.savefig("test.png") 

This produces this image:enter image description here

I wanted to only show the xaxis, which worked using spines, but now it plots these hanging tickmarks for the right-hand yaxis. How can I remove these? id like to keep the ytickmarks on the left hand side of the plot and make them face out (direction opposite to bars). I know that I can remove the ytickmarks altogether by uncommenting the line:

#ax.yaxis.set_tick_params(size=0)

but i want to keep the ytick marks only on the left hand side. thank you.

EDIT: I achieved a solution after some trial and error though i’m sure my solution is probably not the best way to do it, so please let me know what you think still. i found that i can do:

ax.spines["left"].axis.axes.tick_params(direction="outward") 

to set the tick mark direction. to get rid of the right y-axis ticks, i use:

ax.yaxis.set_ticks_position("left")
  • 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-28T17:02:22+00:00Added an answer on May 28, 2026 at 5:02 pm

    you could simply use:

    ax.tick_params(axis='y', direction='out')
    

    this will orientate the ticks as you want. And:

    ax.yaxis.tick_left()
    

    this will not plot the right ticks

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

Sidebar

Related Questions

Consider the following code: from numpy import log2 import matplotlib.pyplot as plt xdata =
i have the following code: import scipy as sc import matplotlib.pyplot as plt ....
I have the following code: import matplotlib.pyplot as plt cdict = { 'red' :
I have installed numpy1.3,scipy 0.7.1,matplotlib 0.99.1.1 and python 2.5 when I import pylab I
I have this bit of code that plots out the points: import matplotlib.pyplot as
I have stumbled accross the following snippet, for creating horizontal bar chart using matplotlib:
I am playing with matplotlib - I have a bar chart, and I want
Say that I have two figures in matplotlib, with one plot per figure: import
I am currently using matplotlib.pyplot to create graphs and would like to have the
I am trying to make a matplotlib figure that will have multiple horizontal boxplots

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.