グラフを描写するさいに縦軸の調整をしたいです
python
1import numpy as np 2import random 3import matplotlib.pyplot as plt 4 5class Agent: 6 def __init__(self,agent_id): 7 self.lp = {} 8 def First_set(self,agents): 9 for agent in agents: 10 if agent is self: 11 continue 12 likability = np.random.uniform(low=-1, high=1, size=None) 13 self.lp[agent.id] = likability 14 15class Simulation: 16 def __init__(self): 17 self.agents = [] 18 19 def generate_agents(self, agents_num): 20 self.agents = [Agent(agent_id) for agent_id in range(agents_num)] 21 for agent in self.agents: 22 agent.First_set(self.agents) 23def run(): 24 num_episode = 5 25 fav = [] 26 for episode in range(num_episode): 27 Simulation() 28 for agent in sim.agents: 29 for age in sim.agents: 30 if age is agent: 31 continue 32 fav.append(agent.lp[age.id]) 33 34 plt.hist(fav, range=(-1,1),histtype="step") 35 plt.show() 36run()
このコードの結果をグラフにしたいのですが、縦軸の範囲が大きくなってしまうので、縦軸を範囲を調整して0~30の範囲で正規化したいのですがどのようなコードを書けばいいですか
回答1件
あなたの回答
tips
プレビュー