How / Where to download Pylab for Python 2.7 on Win32? - python

I have googled all over, and don't see where to get pylab.
What am I missing?
Thanks!

I believe there are two "versions" of pylab floating around/being referred to.
The first is a part of matplotlib -- you just install matplotlib and do either import pylab or import matplotlib.pyplot as pyplot. (More info on pylab vs pyplot).
The second is described here, and as far as I know, doesn't exist yet. The linked version is simply describing a hypothetical vision of what the existing version of pylab could be. It's also unfortunately the first result when you try googling "pylab", which I suspect is what caused your confusion.
Source: http://matplotlib.1069221.n5.nabble.com/pylab-td23420.html#a23423

You can get it as part of EPD's Canopy distribution.

Related

Autocomplete and Syntax Highlighting do not work for matplotlib

I am using VS Code for coding python and I am having an issue regarding Matplotlib: Usually Autocomplete and Syntax Highlighting work fine but not with matplotlib. There everything is just white and I get no proposals. See this example:
I am using a virtual environment with python 3.10.8.
Do you have any ideas on how to fix this issue? Thank you!
Edit:
It is not only a VS Code problem. I also do not get any hints in pycharm.
mpl.figure
mpl.Axes
What you called is the method in the pyplot module in matplotlib. If you run your code, an error will also be reported.
Use the following code to declare your mpl
import matplotlib.pyplot as mpl
If the problem cannot be solved, please paste your import code. I will try to reproduce the problem.

How to fix Object of type ndarray is not JSON serializable while using mpld3?

Python mpld3 '.show()' Gives me this error "Object of type ndarray is not JSON serializable"
I know that there are many duplicates of this question here, however, I haven't been able to find a recent one. This seems to be a common problem with mpld3.
Using Matplotlib version 3.1.3
Using mpld3 version 0.3
I'm also using Anaconda and did a conda upgrade --all and a conda update --all and still get this error.
Here is some code to reproduce the error. [It's really simple]
import matplotlib.pyplot as plt
import mpld3
fig, ax = plt.subplots()
x, y = [[1,2,3],[4,3,2]]
ax.scatter(x, y)
mpld3.show()
Any idea on a quick fix? Or if someone more knowing than I, could post this somewhere where it can be addressed appropriately?
The code above is just a bare bones example to show that there are no numpy arrays being used in the plot creation itself. It is no way a representation of what I'm trying to do [Show a matplotlib figure on a webpage in a simple way]. I know that matplotlib uses numpy internally, so it must be some issue with mpld3 parsing the figure properties dictionary.
I had the same issue as you and I was able to reproduce with your code.
I was just testing a fresh installed mpld3 when I encountered this error.
What I did to fix it is to uninstall mpld3 (which I had installed with pip) and re-install it with conda.
Then it worked.
Checking version with conda list gives me the same versions of both package as you have.
I remember reading that one should not play with both pip and conda for python package managing. I always forget to apply to this rule.
Hope it will fix it for you.

I can't find ConvexHull in scipy.spatial

Edit: As far as I can tell it's an issue with the build, I haven't figured out exactly what yet, but I've narrowed it down to that. For anyone reading this, try the suggestion in the marked answer first.
I'm trying to use the ConvexHull function from the scipy library to compute the convex hull for some points, but scipy.spatial.ConvexHull doesn't seem to exist.
The documentation has this as an example:
from scipy.spatial import ConvexHull
points = np.random.rand(30, 2) # 30 random points in 2-D
hull = ConvexHull(points)
I tried to use this example in my project but couldn't get it to work..
I typed in the appropriate import line but ConvexHull was not found, PyCharm underlined the ConvexHull reference in red, and a mouse-hover shows a 'not found' message.
I've found various mentions on SO about different methods that might be required for importing and using parts of scipy, which I've tried and none of them seem to work, including the import line in the docs example.
I'm running Python 3.6 inside a clean PyCharm venv that I've just created. The pip install of scipy worked fine and scipy is appearing when I try to import it, as is spatial... but ConvexHull doesn't seem to exist.
I'm using scipy 1.1.0, and I've tried using the import that a deleted answer provided...
from scipy.spatial.qhull import ConvexHull... but this didn't work.
Alternately, if this won't work then I am willing to use a different library if possible.
https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.ConvexHull.html
Did you try
from scipy import spatial
spatial.ConvexHull
In 1.0.1 both of these work
In [2]: spatial.qhull.ConvexHull?
In [3]: spatial.ConvexHull?
Glancing at the github issues, there may be some build issues, involving cython versions, that may prevent building the qhull file.
https://github.com/scipy/scipy/issues/8562 - CI: Appveyor builds fail because it can't import ConvexHull from spatial.qhull
I upgraded to 1.1.0, and had no problem accessing ConvexHull.

How matplotlib works?

I know this may sound like a nooby question but I am new to python and am trying to graph some stock data using pandas. I know this is not technically a programming question but do I need to install anything special for the graph to print or does it just graph in the IDE console? Or none of the above? Thanks in advance
Welcome to the world of python programming!
To graph using Matplotlib, first you would have to ensure it is installed in your system:
pip install matplotlib
And then import it into your code using
import matplotlib.pyplot as plt #import the plotting method in Matplotlib
Following this import and creating your plot, you can have your plot shown using
plt.show()

How to find GLCM matrix in python?

We are using Python 2.7.9.and scikit image library. We are not able to use skimage.feature.greycomatrix because there is no file such as greycomatrix.py in the feature folder. Their documentation seems to be wrong as it says this function is available. We get an error module attribute has no object feature. Is there any other image processing library in Python which will help us achieve this goal?
from skimage.feature import greycomatrix
This works for me, just like the instructions at http://scikit-image.org/docs/dev/auto_examples/plot_glcm.html.
Maybe you just have an old version and need to update scikit-image? Or if it was actually a bug on their behalf they have probably fixed it now.
Which version of scikit-image do you have? That is more relevant for this problem than your Python version. For me:
import skimage
print skimage.__version__
'0.11.2'
So for version 0.11.2 up atleast it should work.
In my case I use the following imports and it works for me.
I say
import skimage.feature as sk
##Then I say
glcm = sk.greycomatrix(img, [1],[0])
This should work fine.

Categories

Resources