Scorbie wrote:Python +
matplotlib?
Disclaimer: I have only heard of it.
"matplotlib tries to make easy things easy and hard things possible" -- that certainly sounds promising. (Also, they're taking more than a subtle cue from Perl there, aren't they.)
I'll look into it, thanks!
EDIT: not much luck so far. Cygwin doesn't provide a package, and the pip package can't even be installed:
Code: Select all
$ pip install matplotlib
[...]
running build_ext
building 'matplotlib.ft2font' extension
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-gwez0e7l/matplotlib/setup.py", line 277, in <module>
**extra_args
File "/usr/lib/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.4/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/usr/lib/python3.4/distutils/command/install.py", line 539, in run
self.run_command('build')
File "/usr/lib/python3.4/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.4/distutils/command/build.py", line 126, in run
self.run_command(cmd_name)
File "/usr/lib/python3.4/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.4/site-packages/setuptools/command/build_ext.py", line 50, in run
_build_ext.run(self)
File "/usr/lib/python3.4/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/usr/lib/python3.4/distutils/command/build_ext.py", line 448, in build_extensions
self.build_extension(ext)
File "/usr/lib/python3.4/site-packages/setuptools/command/build_ext.py", line 183, in build_extension
_build_ext.build_extension(self, ext)
File "/usr/lib/python3.4/distutils/command/build_ext.py", line 500, in build_extension
include_dirs=ext.include_dirs,
File "/tmp/pip-build-gwez0e7l/matplotlib/setupext.py", line 785, in __get__
result = obj._hooks[self._name]() + result
File "/tmp/pip-build-gwez0e7l/matplotlib/setupext.py", line 805, in include_dirs_hook
import numpy
File "/usr/lib/python3.4/site-packages/numpy/__init__.py", line 170, in <module>
from . import add_newdocs
File "/usr/lib/python3.4/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python3.4/site-packages/numpy/lib/__init__.py", line 17, in <module>
from . import scimath as emath
ImportError: cannot import name 'scimath'
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-gwez0e7l/matplotlib/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-bb_8_3xg-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-gwez0e7l/matplotlib/
$
Google's not helpful, either. So, no dice with Cygwin.
There's apparently precompiled binaries for Python on Windows, but Python itself (3.5.2) can't be installed, failing with "0x80080005 server execution failed" and advising me to check its install log (which of course contains nothing whatsoever related). But it matters little, because there are
not actually any precompiled windows packages anyway, either for 3.5 or the older 2.7 I still have installed for use with Golly.
So currently I'm downloading an 800 MiB bundle called Python(x, y) which bundles matplotlib and which I
hope will finally actually work.
EDIT 2: matplotlib as bundled with Python(x, y) works, but Python(x, y) itself does not contain the python27.dll file needed for Python scripts in Golly. And unfortunately it also cannot coexist with a vanilla Python 2.7, so this isn't a solution either.
OTOH I was able to pip-install matplotlib on Cygwin's Python after installing the (unrelated, IMO, but what do I know) gtk 2.0 library/headers packages. After also installing statsmodels (which necessitated, among other things, LAPACK and a Fortran compiler) I whipped up this:
- lFaLDip.png (49.42 KiB) Viewed 242 times
Which is a good start. Script:
Code: Select all
#!/usr/bin/python3
import numpy as np
import matplotlib.pyplot as plt
import statsmodels.api as sm
# read data file
datafile=open("xs_scatterplot.dat","rb")
x, y=np.loadtxt(datafile,delimiter="\t",skiprows=1,unpack=True)
# generate a scatter plot
fig, ax=plt.subplots()
ax.scatter(x, y, label='Still lifes')
ax.set_yscale('symlog', linthreshy=1)
ax.set_xlabel('Population', fontsize=15)
ax.set_ylabel("Count", fontsize=15)
ax.set_title('Total still lifes', fontsize=20)
plt.ylim(ymin=0)
ax.grid(True)
fig.tight_layout()
# plot linear fit
logy=np.log(y)
coefficients=np.polyfit(x, logy, 1)
polynomial=np.poly1d(coefficients)
ys=polynomial(x)
plt.plot(x, np.exp(ys), label='Linear fit')
# plot LOWESS fit
lowess=sm.nonparametric.lowess
z=lowess(logy, x, frac=0.3, it=3, return_sorted=False)
plt.plot(x, np.exp(z), label=r'LOWESS fit, $\alpha=0.3$')
# add legend
plt.legend(loc='upper right')
# save plot to file
fig.set_size_inches(8, 8)
plt.savefig("xs_scatterplot.png", dpi=80)
Data:
Code: Select all
Population Count
4 38443380059190
5 5387615762362
6 23554442686741
7 6224388388190
8 1188573288568
9 6330295738
10 4315921916
11 1276821800
12 192563548091
13 162807618
14 73766540016
15 436861751
16 2759365374
17 145246934
18 519150780
19 18213412
20 64918210
21 1507933
22 9586023
23 468929
24 422767
25 216249
26 146749
27 31728
28 3027923
29 9266
30 45332
31 17680
32 7284
33 181
34 304
35 24
36 55
37 9
38 410
39 4
40 5265
41 2
42 65
45 1
46 1
I'm fairly happy with how sane matplotlib's defaults are and how good its plots look without much tweaking -- most of the time required for this was installing Python modules, figuring out issues with the same, and trying to understand matplotlib's documentation.