在Juniper Notebook / Python / Matplotlib中显示笛卡尔积的图表/图形选项? [英] Diagram/Graphical options to display cartesian product in Juniper Notebook/Python/Matplotlib?

查看:136
本文介绍了在Juniper Notebook / Python / Matplotlib中显示笛卡尔积的图表/图形选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将使用49个选项(7行7列)。





这里的代码:

  import numpy as np 
import matplotlib.pylab as plt

nx,ny = 3,5
obs = np.random.randint(10,size =(nx,ny))#随机观测矩阵
activity1 = ['talk', 'listen','recreate','commerce','nothing]]
activity2 = ['stand','sit','lay']

#-图形-
图,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(学校项目的活动矩阵,fontweight =粗体);
plt.show()
fig.savefig(’school_project.png’,transparentity = True)


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).

解决方案

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)

这篇关于在Juniper Notebook / Python / Matplotlib中显示笛卡尔积的图表/图形选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆