Diagram/Graphical options to display cartesian product in Juniper Notebook/Python/Matplotlib?

谁说胖子不能爱 提交于 2019-12-08 05:09:43

问题


I'll working with 49 options (7 rows, 7 columns).

Here is an example

I'm observing what people do (position x actions) in public plazas (total of four) for a school project. I probabily will show it over a large range of time: Each hour from 8AM to 8PM in working days and in weekend days. The main idea is to understand how the plaza is used by people.

I notice the most comon situation is: standing AND talking, sit AND talk, sit AND reading, standing AND recreation. But I found some option like: just sitting, so, only one row (position) without correlation with column (action).


回答1:


If you observe, that people do nothing, then you must take 'do nothing' into your observational list. You could evaluate/display the observational matrix with a heat plot:

Here the code:

import numpy as np
import matplotlib.pylab as plt

nx, ny = 3,5
obs = np.random.randint(10, size=(nx, ny))  # a random observational matrix
activity1 = ['talk', 'listen', 'recreate','commerce','nothing']
activity2 = ['stand','sit', 'lay']

#--- graphics----
fig, ax = plt.subplots()
im = ax.imshow(obs)
ax.set_yticks(np.arange(nx))
ax.set_xticks(np.arange(ny))
ax.set_xticklabels(activity1)
ax.set_yticklabels(activity2)
plt.setp(ax.get_xticklabels(), rotation=45, ha="right", rotation_mode="anchor")
for i in range(nx):
    for j in range(ny):
        text = ax.text(j, i, obs[i, j],
                       ha="center", va="center", color="w")
plt.title('Activity matrix of school project',fontweight='bold'); 
plt.show()
fig.savefig('school_project.png', transparency=True)


来源:https://stackoverflow.com/questions/54947281/diagram-graphical-options-to-display-cartesian-product-in-juniper-notebook-pytho

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!