I need help to highlight the Axis OX and OY in matplotlib.pyplot. Im using it to render function graphs and without highlited OX and OY graphs look unfinished. Here's my code:
import matplotlib.pyplot as plt
import numpy as np
def render_func_graph(formula, x_range):
try:
fig = plt.figure()
x = np.array(x_range)
y = eval(formula)
print(y)
plt.plot(x, y, 'go-')
plt.scatter(0,0)
plt.grid(True)
plt.show()
except Exception as err:
print(str(err))
def main():
func = input('f(x):')
render_func_graph(func, range(-10, 10))
if __name__ == '__main__':
main()
And i'm getting this for 1/x formula

And i want to get something like this
Take a look here, it looks like you could use
#matplotlib.pyplot.axes(*args, **kwargs) -> could just modify axis color
#matplotlib.pyplot.axhline(y=0, xmin=0, xmax=1, hold=None, **kwargs)
axhline(linewidth=4, color='r') #adds thick red line @ y=0
#matplotlib.pyplot.axvline(x=0, ymin=0, ymax=1, hold=None, **kwargs)
axvline(linewidth=4, color='r') #adds thick red line @ x=0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With