Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
first time in python
#1
Hello,

Anyone who can tell me how to plot something like this:
f = f(x)
g = function with variable f = g(f)
h = function of g = h(g)

T = k(h(g(f)))

plot T(x)
Thanks!

E.g. f = sin(x)
g = 5 + f**2
h = 1 - log(g)
T = f - g**2 + sin(h)
Reply
#2
By algebra substitution you are wanting to plot the function
sin(x)-(5+sin(x)**2)**2 + sin(1-log(5+sin(x)**2)). Correct?

My opinion, YMMV, is to use matplotlib and I find it easiest with Pandas
BTW - around here you will find that folks want you to start, try doing things, and then post a question about how far you got and what needs to be fixed. What I am posting here should cause you to think and give you leads about what to look at next - docs for Pandas and docs for matplotlib, for example. That plus a few youtube videos and you should be on your way.

import pandas as pd
import matplotlib.pyplot as plt
import math

def fn_generator(x) :
    return math.sin(x)-(5+math.sin(x)**2)**2 + math.sin(1-math.log(5+math.sin(x)**2))
    
data = []
for x in range(1,10000):
    data.append([x,fn_generator(x/100)])

df = pd.DataFrame(data)
df.columns = ['count','amount']

df.plot(kind="line", x='count', y='amount')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to change UTC time to local time in Python DataFrame? SamKnight 2 1,619 Jul-28-2022, 08:23 AM
Last Post: Pedroski55
  Getting error in finding time.time() value in python Lakshana 1 2,508 Jan-11-2018, 07:07 AM
Last Post: wavic

Forum Jump:

User Panel Messages

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