当前位置: 首页>>代码示例>>Python>>正文


Python MatplotlibWidget.draw方法代码示例

本文整理汇总了Python中matplotlibwidget.MatplotlibWidget.draw方法的典型用法代码示例。如果您正苦于以下问题:Python MatplotlibWidget.draw方法的具体用法?Python MatplotlibWidget.draw怎么用?Python MatplotlibWidget.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlibwidget.MatplotlibWidget的用法示例。


在下文中一共展示了MatplotlibWidget.draw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: UIMainWindow

# 需要导入模块: from matplotlibwidget import MatplotlibWidget [as 别名]
# 或者: from matplotlibwidget.MatplotlibWidget import draw [as 别名]

#.........这里部分代码省略.........
        self.time_edit_secondary.timeChanged.connect(self.change_data_parameters)
        self.spin_box_limit.valueChanged.connect(self.change_data_parameters)
        self.btn_reset_map.clicked.connect(self.reset_map)
        
        # We want to call it so the text is correct at the beginning
        self.change_data_parameters()
        
        self.get_map()
    
    def setup_vars(self):
        print("Loading map...")
        # Sets up variables for use in program
        self.gm = GetMap()
        self.img, self.fig, self.ax, self.imgplot = self.gm.get_current_map()
        
        self.bike_accidents = BikeAccidents()
        self.earliest_date = pd.to_datetime(self.bike_accidents.min_date)
        self.latest_date = pd.to_datetime(self.bike_accidents.max_date)
        self.getting_looking = "looking for"
    
    def calculate_data_map(self):
        self.getting_looking = "getting"
        self.change_data_parameters()
        
        # Filters out the data
        data = self.bike_accidents.accident_range(start_time=self.ptime,
                                                  end_time=self.stime,
                                                  include_unknown_time=self.include_unknown,
                                                  start_date=self.pdate.strftime("%Y-%m-%d"),
                                                  end_date=self.sdate.strftime("%Y-%m-%d"),
                                                  )
        
        data_accident_location = self.bike_accidents.accident_count(data)  # Groups the data according to location
        self.gm.draw_accidents_by_frequency(data_accident_location, self.top_accidents)
        
        self.matplotlib_map.draw()
    
    def reset_map(self):
        self.gm.reset_map()
        self.matplotlib_map.figure = self.fig
        self.matplotlib_map.draw()
    
    def get_map(self):
        self.matplotlib_map.figure = self.fig
        self.matplotlib_map.draw()
    
    def change_data_parameters(self):
        
        self.top_accidents = self.spin_box_limit.value()
        
        # Checks if our check boxes are checked, to see if we want to use the extreme dates or not
        if self.check_box_date_start.isChecked():
            # Set up so is time date
            self.pdate = self.earliest_date
        else:
            self.pdate = pd.to_datetime(self.date_primary.date().toString())
        
        if self.check_box_date_end.isChecked():
            # Set up so is time date
            self.sdate = self.latest_date
        else:
            self.sdate = pd.to_datetime(self.date_secondary.date().toString())
        
        pdate_y, p_date_m, p_date_d = self.pdate.year, self.pdate.month, self.pdate.day
        sdate_y, sdate_m, sdate_d = self.sdate.year, self.sdate.month, self.sdate.day
        
开发者ID:PeterChernoff,项目名称:MyProjects,代码行数:69,代码来源:main.py


注:本文中的matplotlibwidget.MatplotlibWidget.draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。