Plotting with Python
Python 3.6.5 to be specific.
I'm looking to add some plotting capability to a Python script and I'm having problems using the matplotlib package. I chose the `surface3d_demo.py' example that comes with the package (in /usr/share/doc/packages/python3-matplotlib/examples/mplot3d) to test things out. (Partly because 3-D surface plots are so cool.) Unfortunately, issuing: Code:
$ python3 surface3d_demo.py Editing a copy of the demo script to include the Python3 shebang: Code:
#!/usr/bin/python3 Code:
$ ./surface3d_demo.py In neither case are any error messages issued by Python. All that happens is a shell prompt gets displayed. Without any diagnostic messages, I can't tell if my installation is at fault or whether the demo is missing something. I decided to start with matplotlib because of the examples -- GNUplot's were an valuable resource when learning that package -- but so far I'm quite disappointed with the package. I inserted "print()" commands in many places (pretty self explanatory where they were inserted) in the script and the results are shown below: Code:
fig = Figure(640x480) Ideas on what to do next to debug this? (I'm beginning to think I might be better off writing something that dumps data to disk, generates a GNUplot script, and runs that utility to get the graphics I'm looking for.) I know there are alternatives beside GNUplot---like the Python kinda/sorta clone of R's ggplot2(). Unfortunately, the ggplot package comes with no examples to get started with it. (On the other hand, the non-working matplotlib examples haven't been the leg up on using the package that one would hope.) TIA... UPDATE: From the Matplotlib web page: Quote:
|
None is the return value of functions that don't return anything.
https://stackoverflow.com/questions/...ts-not-showing Code:
pacman -S python-matplotlib I don't have numpy installed. And I'm not up to date.(arch) Too far out of date to get numpy. I'll have to do a pacman -Syu to get that. I don't know this. but there are a bunch of examples in the docs. https://matplotlib.org/3.1.1/contents.html https://matplotlib.org/3.1.1/api/pyplot_summary.html https://matplotlib.org/3.1.1/api/_as....pyplot.figure https://matplotlib.org/3.1.1/gallery...plots-examples |
1 Attachment(s)
I use perl to create a “config” file, then feed that file to gnuplot. That gives me a graph in a .png file.
I get no feedback on the command line. (Because I haven’t programmed to get any) I have to display the .png file to see the graph. I do that on a web page. Attachment 31528 Any new files in your working directory? ;) |
Quote:
There are, allegedly, four ways to define the output for matplotlib plots/graphs. The one that's worked so far is to use the line: Code:
matplotlib.use('<backend-name>') I haven't tried the other two means of defining the backend yet. I doubt, though, that those are going to get me past the other problem I'm going to face... Ultimately, my goal is/was to have the script display output on X11 while I'm adjusting parameters but to, ultimately, dump it to an ".eps" file for incorporation into LaTeX documents. But, when I try that, I get: Code:
This call to matplotlib.use() has no effect because the backend has already Re: Your plot generation method: In the past, I've done something similar to your solution by creating an Encapsulated PostScript output file and "watching" it with either "gv" or "okular". If I change the parameters and replot, the plot is automatically updated. That could also be a way to deal with the "can only use matplotlib.use once" problem I ran into. Anyway... My initial problem is solved to a large extent and I'll mark this topic 'solved'. |
Quote:
Quote:
Code:
printf( "Hello, World!\n" ); |
All times are GMT -5. The time now is 03:19 AM. |