Did you see the tutorials and the external ressources pages on the Matplotlib website?

I am giving you the "testing" (devdocs) version because the documentation went through a lot of improvements (IMO ;)) for our incoming 2.1 version. But you should be able to find similar pages even on the non-devdocs web site if you prefer to use this one.

Besides, with an interactive shell like IPython, you can easily get the documentation associated with a peculiar command by postpending a question mark to it (`command_i_want_to_better_know?`) and if you are using an IDE like Spyder, this kind of software usually provides a way to display the same information (click on the command and then Ctrl-I if I remember correctly in the case of Spyder).

Hopefully this will help you.

>

>> On Sep 26, 2017, at 6:20 PM, Ryan May <

[hidden email]> wrote:

>>

>> William,

>>

>> Don't use plt to call all of the methods, but directly use them off

>of the Figure (e.g. fig1) and Axes (e.g. ax1) instances you create:

>>

>

>Thanks, that did it. Very grateful.

>

>Parenthetically, I wish there were a matplotlib book that explained the

>underlying logic of mil plotting. Every one I’ve looked into so far is

>full of specific cookbook examples, but they don’t explain what the

>various calls really do, what order they need to be called in (and

>why), and how they affect each other. Cookbooks are fine for doing

>things by rote, but they don’t provide understanding. If anyone on this

>list knows of such a book, I’d really appreciate hearing.

>

>Thanks,

>Bill

>

>> import numpy as np, matplotlib.pyplot as plt

>>

>> def problem(xdata, ydata, i):

>> color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"}

>> fig1, ax1 = plt.subplots()

>> ax1.plot(xdata, ydata, linestyle = '-', color = color_dic[i])

>> fig1.savefig('Plot for run_num ' + str(i))

>> return

>>

>> def problem_alt(xdata, ydata, i):

>> return

>>

>> t = np.arange(0.0, 2.0, 0.01)

>> fig2, ax2 = plt.subplots()

>>

>> for i in range(0,4):

>> i = i+1

>> problem(t, np.sin(i*np.pi*3*t), i)

>> problem_alt(t, np.sin(i*np.pi*3*t), i)

>> ax2.set_xlim(xmin = 0.0, xmax = 20.0)

>> ax2.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3)))

>>

>> fig2.savefig("Global Plot")

>>

>> At least, I think that's what you're going for. Note I removed some

>extra calls to figure() and subplot() that I don't think were helping

>you.

>>

>> Ryan

>>

>> On Tue, Sep 26, 2017 at 3:04 PM, William Ray Wing <

[hidden email]
><mailto:

[hidden email]>> wrote:

>> Below is a simplified version of a much more elaborate analysis code,

>but it will illustrate the problem I’m having. What I want to do is

>repetitively call an analysis function from my main code and plot the

>results of that analysis (a curve fit, although thats immaterial here)

>while in that function. Back in the main code, I want to plot the

>results of all the curve fits on a single plot. They share a common x

>axis, but appear at different points along it. What seems to be

>happening is that the gets set in the function, and doesn’t get set

>back in the main code.

>>

>> Note that there are two versions of the “problem” function, problem

>and problem_alt. If you change the main code (move the #), you get the

>plot I want at the end of the main.

>>

>> There must be something I can call or set to recover the settings

>associated with figure(2), but I can’t seem to figure it out. Any help

>would be appreciated.

>>

>> Thanks,

>> Bill Wing

>>

>> #! /usr/bin/env python

>> # -*- coding: utf-8 -*-

>> #

>> # A simple skeleton of the program to work out the plotting problem

>> #

>> import numpy as np, matplotlib.pyplot as plt

>> #

>> # skeleton subroutines

>> #

>>

>> def problem(xdata, ydata, i):

>> color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"}

>> plt.figure(1)

>> fig1, ax1 = plt.subplots()

>> plt.subplot()

>> plt.plot(xdata, ydata, linestyle = '-', color = color_dic[i])

>> plt.savefig('Plot for run_num ' + str(i))

>> return

>>

>> def problem_alt(xdata, ydata, i):

>> return

>>

>>

>> t = np.arange(0.0, 2.0, 0.01)

>> plt.figure(2)

>> fig2, ax2 = plt.subplots()

>>

>> for i in range(0,4):

>> i = i+1

>> problem(t, np.sin(i*np.pi*3*t), i)

>> problem_alt(t, np.sin(i*np.pi*3*t), i)

>> ax2.set_xlim(xmin = 0.0, xmax = 20.0)

>> plt.subplot()

>> plt.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3)))

>>

>> plt.savefig("Global Plot")

>>

>> _______________________________________________

>> Matplotlib-users mailing list

>>

[hidden email] <mailto:

[hidden email]>

>>

https://mail.python.org/mailman/listinfo/matplotlib-users><

https://mail.python.org/mailman/listinfo/matplotlib-users>

>>

>>

>>

>> --

>> Ryan May

>>

Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.