Ask Your Question
0

Syntax to define a Layout of a Plot

asked 2020-04-06 03:37:32 -0500

geroyx gravatar image

updated 2020-04-06 03:38:36 -0500

Just for interest:
I have

reset()
import scipy.stats
n = 2000
p = 0.2
binom_dist = scipy.stats.binom(n,p)
bar_chart([binom_dist.pmf(x) for x in range(n)], frame=True, axes_labels=['$k$','$B(k,{},{})$'.format(n,float(p))])

How could outsource the part like
Layout = frame=True, axes_labels=['$k$','$B(k,{},{})$'.format(n,float(p))]?

And then

bar_chart([binom_dist.pmf(x) for x in range(n)], Layout)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2020-04-06 05:54:31 -0500

Juanjo gravatar image

Just put layout options in a dictionary:

reset()
import scipy.stats
n = 2000
p = 0.2
binom_dist = scipy.stats.binom(n,p)
Layout = {'frame': True, 'axes_labels': ['$k$', f'$B(k,{n},{float(p)})$']}
bar_chart([binom_dist.pmf(x) for x in range(n)], **Layout)

or, as an alternative syntax, you can replace the assigment to Layout by

Layout = dict(frame=True, axes_labels=['$k$', f'$B(k,{n},{float(p)})$'])
edit flag offensive delete link more

Comments

Ah, very good! ;)

geroyx gravatar imagegeroyx ( 2020-04-06 06:02:48 -0500 )edit

I have to use your code in the kind
Layout = dict(frame=False, axes_labels=['$k$','$B(k,{},{})$'.format(n,float(p))]) bar_chart([binom_dist.pmf(x) for x in range(n)], **Layout)

But this way it works.

geroyx gravatar imagegeroyx ( 2020-04-06 06:54:57 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-04-06 03:37:32 -0500

Seen: 67 times

Last updated: Apr 06