matplotlib

Clearing and plotting mathplot figure on tkinter

為{幸葍}努か 提交于 2021-02-10 12:57:04
问题 I need some help for my current code. I want to create a window by tkinter and show a plot in a canvas I created by matplotlib before. This point I reached yet. My problem is that I want to clear this canvas by hitting a button. To clear a canvas I suppose to initialize this before I can fill it with the plot. So my question is: How can I fill a plot in a created canvas? Below you can find a small code that shows my state of arts. from matplotlib.figure import Figure from matplotlib.backends

If I import a package into python, do I also have to important it's modules separately?

偶尔善良 提交于 2021-02-10 12:19:23
问题 Very simply, I'm reasonably new to coding, and I'm going through another person's code to understand what it is doing as I have to use it for data analysis but I notice that they do the following: import matplotlib.pyplot as plt . . . import matplotlib as mpl import numpy as np . . import matplotlib.ticker I thought that " import matplotlib as mpl " would import all modules contained in matplotlib and therefore there need to separately import the module " ticker " from matplotlib after this?

How to overlay one pyplot figure on another

大城市里の小女人 提交于 2021-02-10 12:07:46
问题 Searching easily reveals how to plot multiple charts on one figure, whether using the same plotting axes, a second y axis or subplots. Much harder to uncover is how to overlay one figure onto another, something like this: That image was prepared using a bitmap editor to overlay the images. I have no difficulty creating the individual plots, but cannot figure out how to combine them. I expect a single line of code will suffice, but what is it? Here is how I imagine it: bigFig = plt.figure(1,

xlabel and ylabel values are not sorted in matplotlib scatterplot

走远了吗. 提交于 2021-02-10 12:06:54
问题 I have done tedious amounts of searching on the internet and it seems that I have not been able to figure out how to ask the right question to get the answer for what I want to do. I am trying to create a scatterplot with P/E ratio on the y-axis and Dividend Yield on the x-axis. I put the data into a CSV file and then imported each column into Python as individual lists. Here is how my scatterplot turns out below. I am confused why the x- and y- axes are not sorted numerically. I think I have

xlabel and ylabel values are not sorted in matplotlib scatterplot

試著忘記壹切 提交于 2021-02-10 12:04:37
问题 I have done tedious amounts of searching on the internet and it seems that I have not been able to figure out how to ask the right question to get the answer for what I want to do. I am trying to create a scatterplot with P/E ratio on the y-axis and Dividend Yield on the x-axis. I put the data into a CSV file and then imported each column into Python as individual lists. Here is how my scatterplot turns out below. I am confused why the x- and y- axes are not sorted numerically. I think I have

Updating matplotlib plot in tkinter gui via another process

吃可爱长大的小学妹 提交于 2021-02-10 10:13:04
问题 I have an interface that I am writing using tkinter. Inside that interface, I have a matplotlib plot. In the background, I have zmq connecting to a server to get data. I am using python's multiprocessing module with a Queue sharing data and a Process running for all of the zmq communication. In the GUI, I can set up a button to update the plot with the following function: def addData(self): if not self.data.empty(): print "Have Data!" self.hist.addQueue(self.data) self.hist.updatePlot() else:

Embedding an animated matplotlib in tk

别说谁变了你拦得住时间么 提交于 2021-02-10 09:37:28
问题 I am fairly new to python and a real beginner to tkinter and matplotlib. I have the following code which essentially is a testbed for what I eventually want to do. #!/usr/bin/env python import numpy as np from matplotlib import pyplot as plt import time top = 100 plt.ion () # set plot to animated xdata = [] c = 0 for a in range(0,top): xdata.append(a) c+=1 ydata = [ 0 ] * top * 10 ax1 = plt.axes () c = 0 myfile = open("rdata.txt", "r") for myline in myfile: q = myline ydata[c] = q c+=1 c = 0

How to fix plt.tight_layout() error while plotting multiple heatmaps

我与影子孤独终老i 提交于 2021-02-10 09:30:32
问题 I am plotting multiple heatmaps together and don't want them to crowed the space with their axes' labels. I tried to use plt.tight_layout() and it is throw some errors at me. This is my result without plt.tight_layout(): heatmaps without plt.tight_layout() How can I plot these heatmaps together without them overlapping/overcrowding? What do these plt.tight_layout() errors mean? This is the error I get: Traceback (most recent call last): File "C:/Users/mbsta/Desktop/OOL_Research/heatmaptrying

How to fix plt.tight_layout() error while plotting multiple heatmaps

非 Y 不嫁゛ 提交于 2021-02-10 09:26:12
问题 I am plotting multiple heatmaps together and don't want them to crowed the space with their axes' labels. I tried to use plt.tight_layout() and it is throw some errors at me. This is my result without plt.tight_layout(): heatmaps without plt.tight_layout() How can I plot these heatmaps together without them overlapping/overcrowding? What do these plt.tight_layout() errors mean? This is the error I get: Traceback (most recent call last): File "C:/Users/mbsta/Desktop/OOL_Research/heatmaptrying

Custom scientific axis unit for a bar plot with log scale x-axis

别等时光非礼了梦想. 提交于 2021-02-10 07:25:30
问题 Let's consider the following example to plot some y values for given x values. import matplotlib.pyplot as pyplot if __name__ == "__main__": x = [1000000000, 2000000000, 4000000000, 8000000000] y = [0.342, 0.543, 0.874, 1.324] pyplot.bar(x, y) pyplot.savefig("test1.png", format="png") pyplot.close() pyplot.bar([str(int(x_value / 1000000000)) for x_value in x], y) pyplot.savefig("test2.png", format="png") pyplot.close() My goal is to have equally-spaced x-ticks for all x values (i.e., not