Ask Your Question

# Syntax to define a Layout of a Plot

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 close merge delete

## 1 Answer

Sort by ยป oldest newest most voted

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)})$'])

more

## Comments

Ah, very good! ;)

( 2020-04-06 13:02:48 +0200 )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.

( 2020-04-06 13:54:57 +0200 )edit

## Your Answer

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

Add Answer

## Stats

Asked: 2020-04-06 10:37:32 +0200

Seen: 439 times

Last updated: Apr 06 '20