Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with matplotlib
#1
Hello,

I'm trying to make a relatively simple graph in matplotlib but for some reason it keeps coming out looking totally wrong. I'm trying to graph the function E(x)=(-2.408/x) + (9.79x10-5/x10). Here is the code I am using:

import matplotlib.pyplot as plt
import numpy as np
r_x = np.arange(0.2, 1.2, 0.05)
def E(x):
    return -2.408/x + ((9.79E-5)/(x**10))
plt.plot(r_x, E(r_x))
plt.show()
Can someone tell me what I'm doing wrong here? Or why the graph ends up looking completely different than it should? Any help would be appreciated.
Reply
#2
You'll need to tell us how it looks and what part of it looks to be incorrect to you.

Try plotting starting at 0.3 instead of 0.2. I think the default scale is just overwhelming the negative portion where you can't easily see it. You could also fix the vertical axis to what you want to emphasize that portion.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Matplotlib Problem DaveG 0 1,608 Mar-14-2022, 04:05 AM
Last Post: DaveG
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,215 Mar-11-2021, 10:52 AM
Last Post: buran
  Matplotlib problem ift38375 0 1,872 Jul-02-2019, 02:55 PM
Last Post: ift38375
  Matplotlib animation problem Potatoez 1 2,333 May-21-2019, 03:58 PM
Last Post: Potatoez
  Problem installing numpy and matplotlib achondrite 1 3,116 Jan-16-2019, 11:43 PM
Last Post: snippsat
  problem in plotting intraday results using matplotlib mr_byte31 0 2,943 Aug-20-2018, 11:32 AM
Last Post: mr_byte31

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020