save PyMC3 traceplot subplots to image file
I am trying very simply to plot subplots generated by the PyMC3 traceplot function (see here) to a file.
The function generates a numpy.ndarray (2d) of subplots.
I need to move or copy these subplots into a matplotlib.figure in order to save the image file. Everything I can find shows how to generate the figure's subplots first, then build them out.
As a minimum example, I lifted the sample PyMC3 code from Here, and added to it just a few lines in an attempt to handle the subplots.
from pymc3 import *
import theano.tensor as tt
from theano import as_op
from numpy import arange, array, empty
### Added these three lines relative to source #######################
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
__all__ = ['disasters_data', 'switchpoint', 'early_mean', 'late_mean', 'rate', 'disasters']
# Time series of recorded coal mining disasters in the UK from 1851 to 1962
disasters_data = array([4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6,
3, 3, 5, 4, 5, 3, 1, 4, 4, 1, 5, 5, 3, 4, 2, 5,
2, 2, 3, 4, 2, 1, 3, 2, 2, 1, 1, 1, 1, 3, 0, 0,
1, 0, 1, 1, 0, 0, 3, 1, 0, 3, 2, 2, 0, 1, 1, 1,
0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 2,
3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 4, 2, 0, 0, 1, 4,
0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1])
years = len(disasters_data)
@as_op(itypes=[tt.lscalar, tt.dscalar, tt.dscalar], otypes=[tt.dvector])
def rateFunc(switchpoint, early_mean, late_mean):
out = empty(years)
out[:switchpoint] = early_mean
out[switchpoint:] = late_mean
return out
with Model() as model:
# Prior for distribution of switchpoint location
switchpoint = DiscreteUniform('switchpoint', lower=0, upper=years)
# Priors for pre- and post-switch mean number of disasters
early_mean = Exponential('early_mean', lam=1.)
late_mean = Exponential('late_mean', lam=1.)
# Allocate appropriate Poisson rates to years before and after current switchpoint location
rate = rateFunc(switchpoint, early_mean, late_mean)
# Data likelihood
disasters = Poisson('disasters', rate, observed=disasters_data)
# Initial values for stochastic nodes
start = {'early_mean': 2., 'late_mean': 3.}
# Use slice sampler for means
step1 = Slice([early_mean, late_mean])
# Use Metropolis for switchpoint, since it accomodates discrete variables
step2 = Metropolis([switchpoint])
# njobs>1 works only with most recent (mid August 2014) Thenao version:
# https://github.com/Theano/Theano/pull/2021
tr = sample(1000, tune=500, start=start, step=[step1, step2], njobs=1)
### gnashing of teeth starts here ################################
fig, axarr = plt.subplots(3,2)
# This gives a KeyError
# axarr = traceplot(tr, axarr)
# This finishes without error
trarr = traceplot(tr)
# doesn't work
# axarr[0, 0] = trarr[0, 0]
fig.savefig("disaster.png")
I've tried a few variations along the subplot() and add_subplot() lines, to no avail -- all errors point toward the fact that empty subplots must first be created for the figure, not assigned to pre-existing subplots.
A different example (see here, about 80% of the way down, beginning with
### Mysterious code to be explained in Chapter 3.
) avoids the utility altogether and builds out the subplots manually, so maybe there's no good answer to this? Is the pymc3.traceplot output indeed an orphaned ndarray of subplots that can't be used?
python matplotlib pymc3
add a comment |
I am trying very simply to plot subplots generated by the PyMC3 traceplot function (see here) to a file.
The function generates a numpy.ndarray (2d) of subplots.
I need to move or copy these subplots into a matplotlib.figure in order to save the image file. Everything I can find shows how to generate the figure's subplots first, then build them out.
As a minimum example, I lifted the sample PyMC3 code from Here, and added to it just a few lines in an attempt to handle the subplots.
from pymc3 import *
import theano.tensor as tt
from theano import as_op
from numpy import arange, array, empty
### Added these three lines relative to source #######################
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
__all__ = ['disasters_data', 'switchpoint', 'early_mean', 'late_mean', 'rate', 'disasters']
# Time series of recorded coal mining disasters in the UK from 1851 to 1962
disasters_data = array([4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6,
3, 3, 5, 4, 5, 3, 1, 4, 4, 1, 5, 5, 3, 4, 2, 5,
2, 2, 3, 4, 2, 1, 3, 2, 2, 1, 1, 1, 1, 3, 0, 0,
1, 0, 1, 1, 0, 0, 3, 1, 0, 3, 2, 2, 0, 1, 1, 1,
0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 2,
3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 4, 2, 0, 0, 1, 4,
0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1])
years = len(disasters_data)
@as_op(itypes=[tt.lscalar, tt.dscalar, tt.dscalar], otypes=[tt.dvector])
def rateFunc(switchpoint, early_mean, late_mean):
out = empty(years)
out[:switchpoint] = early_mean
out[switchpoint:] = late_mean
return out
with Model() as model:
# Prior for distribution of switchpoint location
switchpoint = DiscreteUniform('switchpoint', lower=0, upper=years)
# Priors for pre- and post-switch mean number of disasters
early_mean = Exponential('early_mean', lam=1.)
late_mean = Exponential('late_mean', lam=1.)
# Allocate appropriate Poisson rates to years before and after current switchpoint location
rate = rateFunc(switchpoint, early_mean, late_mean)
# Data likelihood
disasters = Poisson('disasters', rate, observed=disasters_data)
# Initial values for stochastic nodes
start = {'early_mean': 2., 'late_mean': 3.}
# Use slice sampler for means
step1 = Slice([early_mean, late_mean])
# Use Metropolis for switchpoint, since it accomodates discrete variables
step2 = Metropolis([switchpoint])
# njobs>1 works only with most recent (mid August 2014) Thenao version:
# https://github.com/Theano/Theano/pull/2021
tr = sample(1000, tune=500, start=start, step=[step1, step2], njobs=1)
### gnashing of teeth starts here ################################
fig, axarr = plt.subplots(3,2)
# This gives a KeyError
# axarr = traceplot(tr, axarr)
# This finishes without error
trarr = traceplot(tr)
# doesn't work
# axarr[0, 0] = trarr[0, 0]
fig.savefig("disaster.png")
I've tried a few variations along the subplot() and add_subplot() lines, to no avail -- all errors point toward the fact that empty subplots must first be created for the figure, not assigned to pre-existing subplots.
A different example (see here, about 80% of the way down, beginning with
### Mysterious code to be explained in Chapter 3.
) avoids the utility altogether and builds out the subplots manually, so maybe there's no good answer to this? Is the pymc3.traceplot output indeed an orphaned ndarray of subplots that can't be used?
python matplotlib pymc3
add a comment |
I am trying very simply to plot subplots generated by the PyMC3 traceplot function (see here) to a file.
The function generates a numpy.ndarray (2d) of subplots.
I need to move or copy these subplots into a matplotlib.figure in order to save the image file. Everything I can find shows how to generate the figure's subplots first, then build them out.
As a minimum example, I lifted the sample PyMC3 code from Here, and added to it just a few lines in an attempt to handle the subplots.
from pymc3 import *
import theano.tensor as tt
from theano import as_op
from numpy import arange, array, empty
### Added these three lines relative to source #######################
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
__all__ = ['disasters_data', 'switchpoint', 'early_mean', 'late_mean', 'rate', 'disasters']
# Time series of recorded coal mining disasters in the UK from 1851 to 1962
disasters_data = array([4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6,
3, 3, 5, 4, 5, 3, 1, 4, 4, 1, 5, 5, 3, 4, 2, 5,
2, 2, 3, 4, 2, 1, 3, 2, 2, 1, 1, 1, 1, 3, 0, 0,
1, 0, 1, 1, 0, 0, 3, 1, 0, 3, 2, 2, 0, 1, 1, 1,
0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 2,
3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 4, 2, 0, 0, 1, 4,
0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1])
years = len(disasters_data)
@as_op(itypes=[tt.lscalar, tt.dscalar, tt.dscalar], otypes=[tt.dvector])
def rateFunc(switchpoint, early_mean, late_mean):
out = empty(years)
out[:switchpoint] = early_mean
out[switchpoint:] = late_mean
return out
with Model() as model:
# Prior for distribution of switchpoint location
switchpoint = DiscreteUniform('switchpoint', lower=0, upper=years)
# Priors for pre- and post-switch mean number of disasters
early_mean = Exponential('early_mean', lam=1.)
late_mean = Exponential('late_mean', lam=1.)
# Allocate appropriate Poisson rates to years before and after current switchpoint location
rate = rateFunc(switchpoint, early_mean, late_mean)
# Data likelihood
disasters = Poisson('disasters', rate, observed=disasters_data)
# Initial values for stochastic nodes
start = {'early_mean': 2., 'late_mean': 3.}
# Use slice sampler for means
step1 = Slice([early_mean, late_mean])
# Use Metropolis for switchpoint, since it accomodates discrete variables
step2 = Metropolis([switchpoint])
# njobs>1 works only with most recent (mid August 2014) Thenao version:
# https://github.com/Theano/Theano/pull/2021
tr = sample(1000, tune=500, start=start, step=[step1, step2], njobs=1)
### gnashing of teeth starts here ################################
fig, axarr = plt.subplots(3,2)
# This gives a KeyError
# axarr = traceplot(tr, axarr)
# This finishes without error
trarr = traceplot(tr)
# doesn't work
# axarr[0, 0] = trarr[0, 0]
fig.savefig("disaster.png")
I've tried a few variations along the subplot() and add_subplot() lines, to no avail -- all errors point toward the fact that empty subplots must first be created for the figure, not assigned to pre-existing subplots.
A different example (see here, about 80% of the way down, beginning with
### Mysterious code to be explained in Chapter 3.
) avoids the utility altogether and builds out the subplots manually, so maybe there's no good answer to this? Is the pymc3.traceplot output indeed an orphaned ndarray of subplots that can't be used?
python matplotlib pymc3
I am trying very simply to plot subplots generated by the PyMC3 traceplot function (see here) to a file.
The function generates a numpy.ndarray (2d) of subplots.
I need to move or copy these subplots into a matplotlib.figure in order to save the image file. Everything I can find shows how to generate the figure's subplots first, then build them out.
As a minimum example, I lifted the sample PyMC3 code from Here, and added to it just a few lines in an attempt to handle the subplots.
from pymc3 import *
import theano.tensor as tt
from theano import as_op
from numpy import arange, array, empty
### Added these three lines relative to source #######################
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
__all__ = ['disasters_data', 'switchpoint', 'early_mean', 'late_mean', 'rate', 'disasters']
# Time series of recorded coal mining disasters in the UK from 1851 to 1962
disasters_data = array([4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6,
3, 3, 5, 4, 5, 3, 1, 4, 4, 1, 5, 5, 3, 4, 2, 5,
2, 2, 3, 4, 2, 1, 3, 2, 2, 1, 1, 1, 1, 3, 0, 0,
1, 0, 1, 1, 0, 0, 3, 1, 0, 3, 2, 2, 0, 1, 1, 1,
0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 2,
3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 4, 2, 0, 0, 1, 4,
0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1])
years = len(disasters_data)
@as_op(itypes=[tt.lscalar, tt.dscalar, tt.dscalar], otypes=[tt.dvector])
def rateFunc(switchpoint, early_mean, late_mean):
out = empty(years)
out[:switchpoint] = early_mean
out[switchpoint:] = late_mean
return out
with Model() as model:
# Prior for distribution of switchpoint location
switchpoint = DiscreteUniform('switchpoint', lower=0, upper=years)
# Priors for pre- and post-switch mean number of disasters
early_mean = Exponential('early_mean', lam=1.)
late_mean = Exponential('late_mean', lam=1.)
# Allocate appropriate Poisson rates to years before and after current switchpoint location
rate = rateFunc(switchpoint, early_mean, late_mean)
# Data likelihood
disasters = Poisson('disasters', rate, observed=disasters_data)
# Initial values for stochastic nodes
start = {'early_mean': 2., 'late_mean': 3.}
# Use slice sampler for means
step1 = Slice([early_mean, late_mean])
# Use Metropolis for switchpoint, since it accomodates discrete variables
step2 = Metropolis([switchpoint])
# njobs>1 works only with most recent (mid August 2014) Thenao version:
# https://github.com/Theano/Theano/pull/2021
tr = sample(1000, tune=500, start=start, step=[step1, step2], njobs=1)
### gnashing of teeth starts here ################################
fig, axarr = plt.subplots(3,2)
# This gives a KeyError
# axarr = traceplot(tr, axarr)
# This finishes without error
trarr = traceplot(tr)
# doesn't work
# axarr[0, 0] = trarr[0, 0]
fig.savefig("disaster.png")
I've tried a few variations along the subplot() and add_subplot() lines, to no avail -- all errors point toward the fact that empty subplots must first be created for the figure, not assigned to pre-existing subplots.
A different example (see here, about 80% of the way down, beginning with
### Mysterious code to be explained in Chapter 3.
) avoids the utility altogether and builds out the subplots manually, so maybe there's no good answer to this? Is the pymc3.traceplot output indeed an orphaned ndarray of subplots that can't be used?
python matplotlib pymc3
python matplotlib pymc3
asked Dec 6 '16 at 10:55
GoneAsync
15117
15117
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Can you print type(trarr[0,0])
and post the result?
First of all, matplotlib axes objects are part of a figure and can only live inside a figure. It is therefore not possible to simply take an axes and put it to a different figure. However, in your case it may be, that fig.add_axes(trarr[0,0])
nonetheless works. I doubt it, but you can still try.
Apart from that, traceplot()
has a keyword argument called ax
.
ax : axes
Matplotlib axes. Defaults to None.
Although it is pretty unclear, how you'd specify several subplots as one axes object, you can still try to play around with it. Try to put a single axes in or your own created subplots axes array axarr
or only part of it.
Edit, just that noone oversees the small line in the comments:
According to the answer in the bug report, traceplot(tr, ax = axarr)
is indeed reported to work just fine.
Thanks for your comments. thetype(trarr[0,0])
is <class 'matplotlib.axes._subplots.AxesSubplot'>. I tried thefig.add_axes(...)
suggestion, and got similar error to earlier -- axes need to already exist in the fig. I had also played around with feeding the pre-constructed numpy.ndarray of subplots into the traceplot function, but that generates a whole different thread of errors bug report here.
– GoneAsync
Dec 6 '16 at 21:08
EDIT: if one remembers to use the keywork for the argumenttraceplot(tr, ax = axarr)
, it works fine.
– GoneAsync
Dec 6 '16 at 21:16
add a comment |
I ran into the same problem. I am working with pymc3
3.5 and matplotlib
2.1.2.
I realized it's possible to export the traceplot by:
trarr = traceplot(tr)
fig = plt.gcf() # to get the current figure...
fig.savefig("disaster.png") # and save it directly
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f40993620%2fsave-pymc3-traceplot-subplots-to-image-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Can you print type(trarr[0,0])
and post the result?
First of all, matplotlib axes objects are part of a figure and can only live inside a figure. It is therefore not possible to simply take an axes and put it to a different figure. However, in your case it may be, that fig.add_axes(trarr[0,0])
nonetheless works. I doubt it, but you can still try.
Apart from that, traceplot()
has a keyword argument called ax
.
ax : axes
Matplotlib axes. Defaults to None.
Although it is pretty unclear, how you'd specify several subplots as one axes object, you can still try to play around with it. Try to put a single axes in or your own created subplots axes array axarr
or only part of it.
Edit, just that noone oversees the small line in the comments:
According to the answer in the bug report, traceplot(tr, ax = axarr)
is indeed reported to work just fine.
Thanks for your comments. thetype(trarr[0,0])
is <class 'matplotlib.axes._subplots.AxesSubplot'>. I tried thefig.add_axes(...)
suggestion, and got similar error to earlier -- axes need to already exist in the fig. I had also played around with feeding the pre-constructed numpy.ndarray of subplots into the traceplot function, but that generates a whole different thread of errors bug report here.
– GoneAsync
Dec 6 '16 at 21:08
EDIT: if one remembers to use the keywork for the argumenttraceplot(tr, ax = axarr)
, it works fine.
– GoneAsync
Dec 6 '16 at 21:16
add a comment |
Can you print type(trarr[0,0])
and post the result?
First of all, matplotlib axes objects are part of a figure and can only live inside a figure. It is therefore not possible to simply take an axes and put it to a different figure. However, in your case it may be, that fig.add_axes(trarr[0,0])
nonetheless works. I doubt it, but you can still try.
Apart from that, traceplot()
has a keyword argument called ax
.
ax : axes
Matplotlib axes. Defaults to None.
Although it is pretty unclear, how you'd specify several subplots as one axes object, you can still try to play around with it. Try to put a single axes in or your own created subplots axes array axarr
or only part of it.
Edit, just that noone oversees the small line in the comments:
According to the answer in the bug report, traceplot(tr, ax = axarr)
is indeed reported to work just fine.
Thanks for your comments. thetype(trarr[0,0])
is <class 'matplotlib.axes._subplots.AxesSubplot'>. I tried thefig.add_axes(...)
suggestion, and got similar error to earlier -- axes need to already exist in the fig. I had also played around with feeding the pre-constructed numpy.ndarray of subplots into the traceplot function, but that generates a whole different thread of errors bug report here.
– GoneAsync
Dec 6 '16 at 21:08
EDIT: if one remembers to use the keywork for the argumenttraceplot(tr, ax = axarr)
, it works fine.
– GoneAsync
Dec 6 '16 at 21:16
add a comment |
Can you print type(trarr[0,0])
and post the result?
First of all, matplotlib axes objects are part of a figure and can only live inside a figure. It is therefore not possible to simply take an axes and put it to a different figure. However, in your case it may be, that fig.add_axes(trarr[0,0])
nonetheless works. I doubt it, but you can still try.
Apart from that, traceplot()
has a keyword argument called ax
.
ax : axes
Matplotlib axes. Defaults to None.
Although it is pretty unclear, how you'd specify several subplots as one axes object, you can still try to play around with it. Try to put a single axes in or your own created subplots axes array axarr
or only part of it.
Edit, just that noone oversees the small line in the comments:
According to the answer in the bug report, traceplot(tr, ax = axarr)
is indeed reported to work just fine.
Can you print type(trarr[0,0])
and post the result?
First of all, matplotlib axes objects are part of a figure and can only live inside a figure. It is therefore not possible to simply take an axes and put it to a different figure. However, in your case it may be, that fig.add_axes(trarr[0,0])
nonetheless works. I doubt it, but you can still try.
Apart from that, traceplot()
has a keyword argument called ax
.
ax : axes
Matplotlib axes. Defaults to None.
Although it is pretty unclear, how you'd specify several subplots as one axes object, you can still try to play around with it. Try to put a single axes in or your own created subplots axes array axarr
or only part of it.
Edit, just that noone oversees the small line in the comments:
According to the answer in the bug report, traceplot(tr, ax = axarr)
is indeed reported to work just fine.
edited Dec 6 '16 at 21:25
answered Dec 6 '16 at 14:01
ImportanceOfBeingErnest
126k11129204
126k11129204
Thanks for your comments. thetype(trarr[0,0])
is <class 'matplotlib.axes._subplots.AxesSubplot'>. I tried thefig.add_axes(...)
suggestion, and got similar error to earlier -- axes need to already exist in the fig. I had also played around with feeding the pre-constructed numpy.ndarray of subplots into the traceplot function, but that generates a whole different thread of errors bug report here.
– GoneAsync
Dec 6 '16 at 21:08
EDIT: if one remembers to use the keywork for the argumenttraceplot(tr, ax = axarr)
, it works fine.
– GoneAsync
Dec 6 '16 at 21:16
add a comment |
Thanks for your comments. thetype(trarr[0,0])
is <class 'matplotlib.axes._subplots.AxesSubplot'>. I tried thefig.add_axes(...)
suggestion, and got similar error to earlier -- axes need to already exist in the fig. I had also played around with feeding the pre-constructed numpy.ndarray of subplots into the traceplot function, but that generates a whole different thread of errors bug report here.
– GoneAsync
Dec 6 '16 at 21:08
EDIT: if one remembers to use the keywork for the argumenttraceplot(tr, ax = axarr)
, it works fine.
– GoneAsync
Dec 6 '16 at 21:16
Thanks for your comments. the
type(trarr[0,0])
is <class 'matplotlib.axes._subplots.AxesSubplot'>. I tried the fig.add_axes(...)
suggestion, and got similar error to earlier -- axes need to already exist in the fig. I had also played around with feeding the pre-constructed numpy.ndarray of subplots into the traceplot function, but that generates a whole different thread of errors bug report here.– GoneAsync
Dec 6 '16 at 21:08
Thanks for your comments. the
type(trarr[0,0])
is <class 'matplotlib.axes._subplots.AxesSubplot'>. I tried the fig.add_axes(...)
suggestion, and got similar error to earlier -- axes need to already exist in the fig. I had also played around with feeding the pre-constructed numpy.ndarray of subplots into the traceplot function, but that generates a whole different thread of errors bug report here.– GoneAsync
Dec 6 '16 at 21:08
EDIT: if one remembers to use the keywork for the argument
traceplot(tr, ax = axarr)
, it works fine.– GoneAsync
Dec 6 '16 at 21:16
EDIT: if one remembers to use the keywork for the argument
traceplot(tr, ax = axarr)
, it works fine.– GoneAsync
Dec 6 '16 at 21:16
add a comment |
I ran into the same problem. I am working with pymc3
3.5 and matplotlib
2.1.2.
I realized it's possible to export the traceplot by:
trarr = traceplot(tr)
fig = plt.gcf() # to get the current figure...
fig.savefig("disaster.png") # and save it directly
add a comment |
I ran into the same problem. I am working with pymc3
3.5 and matplotlib
2.1.2.
I realized it's possible to export the traceplot by:
trarr = traceplot(tr)
fig = plt.gcf() # to get the current figure...
fig.savefig("disaster.png") # and save it directly
add a comment |
I ran into the same problem. I am working with pymc3
3.5 and matplotlib
2.1.2.
I realized it's possible to export the traceplot by:
trarr = traceplot(tr)
fig = plt.gcf() # to get the current figure...
fig.savefig("disaster.png") # and save it directly
I ran into the same problem. I am working with pymc3
3.5 and matplotlib
2.1.2.
I realized it's possible to export the traceplot by:
trarr = traceplot(tr)
fig = plt.gcf() # to get the current figure...
fig.savefig("disaster.png") # and save it directly
answered Nov 23 '18 at 5:22
Xiaoyu Lu
417413
417413
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f40993620%2fsave-pymc3-traceplot-subplots-to-image-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown