Get different colored traceplots for each Chain using PyStan

Unlike RStan, PyStan seems to overlapping all traceplot chains with the same color. Is it possible to distinguish the different chains when using the traceplot function?

1 Like

Have you tried arviz traceplot functionality

import arviz as az
...
az.plot_trace(fit)
1 Like

Thank you for your email. I appreciate it. Unfortunately, that doesn’t separate the chains too. I have 8 chains but I can’t view them separately. I think this is a shortcoming of PyStan compared to RStan.

1 Like

PyStan doesn’t have plotting (2.x had, 3.0 does not)

(legend is optional)

az.plot_trace(fit, compact=False, legend=True)
1 Like

You can choose how to encode the chain information in the trace plot using chain_prop argument. I have usage some examples of that at this blogpost.

As @ahartikainen mentioned, setting compact=False defaults to using color to distinguish chains, whereas compact=True (default value from compact) uses color for different dimensions of multidim variables and linestyle for different chains. But both those defaults can be set manually via chain_prop.

2 Likes

Perfect! Thanks a lot.

1 Like