Ask Your Question
0

Syntax to define a Layout of a Plot

asked 2020-04-06 10:37:32 +0100

geroyx gravatar image

updated 2020-04-06 10:38:36 +0100

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 12:54:31 +0100

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 13:02:48 +0100 )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 13:54:57 +0100 )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 10:37:32 +0100

Seen: 664 times

Last updated: Apr 06 '20