<jupyter_start><jupyter_text>"Explaining the Fogg Behavior Model"> "In this post, I would like to explain the Fogg Behavior Model, created by <NAME> (<NAME>)."- toc: true- branch: master- badges: false- hide: false- search_exclude: false- comments: true- author: <NAME>- categories: [productivity, python, matplotlib] In this post, I would like to explain the Fogg Behavior Model, created by <NAME> (<NAME>).According to B. J. Fogg's research, Behavior ($B$) happens at the intersection of three things:our Motivation ($M$), our Ability ($A$), and the Prompt ($P$) to the behavior.$B = MAP$We can visualize the relationship between motivation, ability and the prompt in a two-dimensionalgraphic.I plotted the graphic below using Python and the NumPy and Matplotlib packages.I kept the code for anyone who is interested in how to do it.<jupyter_code>import matplotlib.pyplot as plt
import numpy as np

text = { # text dict for easier translation
    'ability':'Ability',
    'motivation':'Motivation',
    'title':'Fogg Behavior Model',
    'bmap':'B = MAP',
    'bmap_sub':'At the same\nmoment',
    'ability_axis':('Hard to Do', 'Easy to Do'),
    'motivation_axis':('High', 'Low'),
    'action_line':'Action Line',
    'prompts':'Prompts',
    'prompts_succeed':'succeed here',
    'prompts_fail':'fail here',
}

blue_color = '#06abe1'
green_color = '#81a050'
light_green_color = '#d2e5c9'
red_color = '#ff2222'
light_red_color = '#ffcbcb'

# Data for plotting
x = np.arange(0.0, 1.1, 0.01)
# y = 1.05 - sqrt(1 - (x - 1.05) ** 2)
y = 1.05 - np.sqrt([np.max((xi, 0)) for xi in 1 - (x - 1.05) ** 2])

fig, ax = plt.subplots()
ax.plot(x, y, color=green_color)
ax.set(xlabel=text['ability'],
       ylabel=text['motivation'],
       title=text['title'])
ax.tick_params(axis='both', which='both',length=0)
ax.fill_between(x, y, color=light_red_color)
ax.fill_between(x, y, max(y), color=light_green_color)

ax.text(0.65, 0.9, text['bmap'], size=25, color=blue_color)
ax.text(0.82, 0.80, text['bmap_sub'], size=8, color=blue_color)

prompts_size=15
ax.text(0.5, 0.5, text['prompts'], size=prompts_size, color=blue_color)
ax.text(0.5, 0.45, text['prompts_succeed'], size=prompts_size*0.5, color=green_color)
ax.text(0.08, 0.2, text['prompts'], size=prompts_size, color=blue_color)
ax.text(0.08, 0.15, text['prompts_fail'], size=prompts_size*0.5, color=red_color)

# set x axis ticks names
xticks = [''] * (len(x)-10)
xticks[10], xticks[-10] = text['ability_axis']
plt.xticks(x, xticks)
# set y axis ticks names
yticks = [''] * (len(y)-10)
yticks[6], yticks[-1] = text['motivation_axis']
plt.yticks(y, yticks)

# set axis' limits
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.0])

tp = np.array((0.28, 0.45))
trans_angle = plt.gca().transData.transform_angles(np.array((315,)),
                                                   tp.reshape((1, 2)))[0]
plt.text(tp[0], tp[1], text['action_line'], fontsize=12,
         rotation=trans_angle, rotation_mode='anchor')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17224080267558528, 'fraction_numerical': 0.03812709030100334, 'mean_word_length': 4.601123595505618, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '322340', 'license': 'Apache-2.0', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1095, 'n_words': 286, 'path': '_notebooks/2020-03-08-explaining-the-fogg-behavior-model.ipynb', 'repo_name': 'hygorxaraujo/fastpages_personalsite', 'size': '3031'}