0

I have tried the following:

import matplotlib.pyplot as plt
import numpy as np
bb = [1,2,3,4,5,6,7,8,9,10]
cc = ["red","red","yellow","red","green","red","red","green","red","red"]

fig = plt.figure()
fig.set_size_inches(50,70)
ax1 = fig.add_subplot(331)
ax1.bar(np.arange(len(bb)), bb, color=cc,width=0.6)
plt.show()

enter image description here

I want to get the list of x-scale and y-scale of the plot. How I can get it?

Jaffer Wilson
  • 7,029
  • 10
  • 62
  • 139
  • `ax1.get_xticklabels()` and `ax1.get_yticklabels()` ought to work? Or just `locs, labels = plt.xticks()` – Andrew Feb 14 '19 at 11:36
  • Can I get them as integers? And the `plt.xticks()` didn't worked. – Jaffer Wilson Feb 14 '19 at 11:44
  • Why marked as duplicate...? I do not get the values in the list. I want the integral values of y scale and x scale of the axes. – Jaffer Wilson Feb 14 '19 at 12:47
  • And I am not setting the scale but getting the scale. Sir please let me know what you have found useful for me in the mentioned reference as duplicate? – Jaffer Wilson Feb 14 '19 at 12:57
  • @JafferWilson: Try `xlabels = map(int, [item for item in ax1.get_xticks()])` and `ylabels = map(int, [item for item in ax1.get_yticks()])` – Sheldore Feb 14 '19 at 15:06
  • 1
    I'm sorry this isn't working for you the way it does for everyone else. But just copying the solution from the accepted answer should give you [this](https://i.stack.imgur.com/ucb12.png). What happens if you run the code? Feel free to edit the question to show the actual problem you have when applying that solution. – ImportanceOfBeingErnest Feb 14 '19 at 15:12
  • @Bazingaa Ok I will try it out – Jaffer Wilson Feb 15 '19 at 05:54
  • @ImportanceOfBeingErnest Ok sir I will will edit if the current solution isn't workable. – Jaffer Wilson Feb 15 '19 at 05:56
  • @ImportanceOfBeingEarnest: it didn’t work for me either. X_ticks works for me though as I commented – Sheldore Feb 15 '19 at 10:58

0 Answers0