No module named when using PyInstaller
Had a similar problem with no module named FileDialog. Discovered that with version 3.2, I could use pyinstaller –hidden-import FileDialog … instead of modifying my main script.
Had a similar problem with no module named FileDialog. Discovered that with version 3.2, I could use pyinstaller –hidden-import FileDialog … instead of modifying my main script.
Obtain binary image. Load the image, convert to grayscale, then Otsu’s threshold to obtain a binary black/white image. Detect and remove horizontal lines. To detect horizontal lines, we create a special horizontal kernel and morph open to detect horizontal contours. From here we find contours on the mask and “fill in” the detected horizontal contours … Read more
It’s because savefig overrides the facecolor for the background of the figure. (This is deliberate, actually… The assumption is that you’d probably want to control the background color of the saved figure with the facecolor kwarg to savefig. It’s a confusing and inconsistent default, though!) The easiest workaround is just to do fig.savefig(‘whatever.png’, facecolor=fig.get_facecolor(), edgecolor=”none”) … Read more
use LineCollection: import numpy as np import pylab as pl from matplotlib import collections as mc lines = [[(0, 1), (1, 1)], [(2, 3), (3, 3)], [(1, 2), (1, 3)]] c = np.array([(1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1)]) lc = mc.LineCollection(lines, colors=c, linewidths=2) fig, ax = pl.subplots() ax.add_collection(lc) ax.autoscale() … Read more
If I understand well, one of your major concern is the gaps between the daily data. To get rid of them, one method is to artificially ‘evenly space’ your data (but of course you will loose any temporal indication intra-day). Anyways, doing this way, you will be able to obtain a chart that looks like … Read more
I think @Evert has the right answer: plt.scatter(dates,values) plt.plot(dates, values) plt.show() Which is pretty much the same as plt.plot(dates, values, ‘-o’) plt.show() You can replace -o with another suitable format string as described in the documentation. You can also split the choices of line and marker styles using the linestyle= and marker= keyword arguments.
I’m not sure whether it is a new feature in later versions of matplotlib, but at least for 1.3.1, this is simply: plt.title(figure_title, y=1.08) This also works for plt.suptitle(), but not (yet) for plt.xlabel(), etc.
The contents of this answer were merged into mpl master in https://github.com/matplotlib/matplotlib/pull/4342 and will be in the next feature release. Wow… This is a thorny problem… (And it exposes a lot of limitations in matplotlib’s text rendering…) This should (i.m.o.) be something that matplotlib has built-in, but it doesn’t. There have been a few threads … Read more
How about using colors to differentiate between “apples” and “oranges” and spacing to separate “A”, “B” and “C”? Something like this: from pylab import plot, show, savefig, xlim, figure, \ hold, ylim, legend, boxplot, setp, axes # function for setting the colors of the box plots pairs def setBoxColors(bp): setp(bp[‘boxes’][0], color=”blue”) setp(bp[‘caps’][0], color=”blue”) setp(bp[‘caps’][1], color=”blue”) … Read more
I usually use the second one of these: from matplotlib.pyplot import cm import numpy as np #variable n below should be number of curves to plot #version 1: color = cm.rainbow(np.linspace(0, 1, n)) for i, c in zip(range(n), color): plt.plot(x, y, c=c) #or version 2: color = iter(cm.rainbow(np.linspace(0, 1, n))) for i in range(n): c … Read more