Ive been trying to recreate a parametric in python

I’ve been trying to recreate a parametric plot i was given for the last couple of days. This original plot was written in mathematica. This is how it was written in mathematica

And this is what ive tried so far.

          import matplotlib.pyplot as plt
          import numpy as np

          %matplotlib inline

          gamma_0 = 72.8
          temp = 293.15
          def gamma(x_2):
                 return gamma_0 - 0.0187 * temp * math.log(1+628.14*55.556*x_2)



           plt.plot(gamma(x_2))

           plt.xlabel('Log_10*x_2')
           plt.ylabel('gamma (erg cm^2)')

There’s still quite a few steps left on this one. Have you spent much time plotting with matplotlib? If not, break it down into a series of steps you’ll need to complete to obtain this plot. Perhaps you’ll need to learn how to perform each of these steps separately before trying to stick them all together rather than guessing at a complex solution. Maybe start small with a plot of a simpler equation or dataset and then introduce log plots and so on.

I haven’t used it that much. I’m really new to matplotlib and python. Thanks for the advice im not sure where to start though.

Is this a one-off (in which case why not stick with what you do know) or do you plan on using them again in the future?

If you want to learn them for the future there are a number of lessons on Codecademy and elsewhere that you could probably pass through fairly swiftly to learn the basics you’d need to complete this plot (I’m afraid I’m unfamiliar with what is and what isn’t part of the Pro subscription). If not there are innumerable guides online for various Python and matplotlib recipes, along with a number of code snippets which you could just chop and change as necessary for your own plot. It all depends on how best to spend your own time; is it worth the investment or not?

I plan on using them again in the future. Right now i’m using the lesson plan by code academy along with watching videos on YouTube .

1 Like

I was told that i should start with MatLab to learn the Math Methods and then move to python. Would you suggest that too

Depending on what you want it for, you may wish to consider the relative merits/demerits of Python(numpy/pandas + matplotlib), MATLAB and several others, e.g. R, Julia, Mathmetica since they all have certain strengths and weaknesses. Spend a while searching for the best option to save yourself time in the future (guidance from someone with the same background will always be best). A well supported language is always a good start (where most of the questions already have answers) and you can always specialise at a later date as necessary.

As someone who moved from MATLAB for analysing data to numpy/matplotlib I don’t think it’s necessary to math methods with MATLAB. Learn them in whatever language you’re going to use the most, the math itself isn’t going to change. Using numpy and maptplotlib together is fairly similar to the basic set-up of MATLAB though tools/libraries for more complex methods will beign to differ.

MATLAB might be quicker just to start with since it’s desgined for a certain set of uses whereas Python would probably take more effort but is good for a general purpose.

2 Likes

Thank you so much for the advice! I’ve been all over the internet looking for advice and answers. Your’s is the best

1 Like

Just to note, that method is log base e. There is a math.log10() method available.

2 Likes

Thanks ill try that method

1 Like