• 4
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Python Matplotlib - how to specify values on y axis?

I am new to Python and I need to generate a graph using pyplot and matplotlib like the one in the attached picture. So far I tried it like this:

 import matplotlib.pyplot as plt
 import numpy as np

 x = np.array([0,1,2,3])
 y = np.array([20,21,22,23])
 my_xticks = ['John','Arnold','Mavis','Matt']
 plt.xticks(x, my_xticks)
 plt.plot(x, y)
 plt.show()

But my problem is how can I specify a different number of values on the y axis different from the number of values on the x axis? And maybe specify them as an interval with 0.005 difference instead of a list? Many thanks! enter image description here

import matplotlib.pyplot as plt
import numpy as np

x = np.array([0,1,2,3])
y = np.array([0.650, 0.660, 0.675, 0.685])
my_xticks = ['a', 'b', 'c', 'd']
plt.xticks(x, my_xticks)
plt.yticks(np.arange(y.min(), y.max(), 0.005))
plt.plot(x, y)
plt.grid(axis='y', linestyle='-')
plt.show()

Something like this should work.

  • 48
Reply Report

Trending Tags