Closed garyrob closed 8 years ago
Hey Gary, leather is still new and the user documentation is not yet complete. (Thus all the TK's in the examples.) However, if you look at the example code you'll see each call specifies an output file:
chart.to_svg('examples/charts/simple_pairs.svg')
That's where your image is. (Relative to the directory you're running the script in.) You can open that file in your browser or in a vector image editor such as Inkscape.
If you're working within a Jupyter notebook you can leave the path off and the resulting image will be displayed inline. Leather does not currently support a "halt and popup" viewer like you might be familiar with from matplotlib. I don't currently have any plans to support that. (For a lot of reasons we can debate if you feel strongly about it.)
As far as I know there are no issues specific to Anaconda or to any particular operating system, but if you find any please feel additional bug reports! Thanks!
Wow, that's what I get for blindly copying and pasting an example! Thank you for the kindness and patience in your response! :)
So I guess if you're not working in Jupyter, a fairly easy way to display the file would be
chart.to_svg('examples/charts/simple_pairs.svg') from subprocess import Popen; Popen("open -a Firefox examples/charts/simple_pairs.svg", shell=True)
Looks like a very nice package, thanks!
Sure thing! Glad you like it!
I would like to make an easy suggestion... added a displayWith() option, which would save the svg to a temp file and let you open it with whatever app you want:
chart = leather.Chart('Colorized dots') chart.add_dots(dot_data, fill_color=colorizer) chart.displayWith('Firefox')
It could default to Safari on the Mac, IE on Windows, etc. It certainly appears like it would be easy to do on the Mac. I can understand why you wouldn't want to rely on some other installed Python package, but this seems fairly straightforward.
Just my 2 cents, probably worth everything you paid for them! :)
There may actually already be an easy solution to this using the built-in webbrowser module.
However, making stuff like this work cross-platform is notoriously fraughts, so I'll have to investigate a bit further.
Interesting... on my system, webbrowser.open() tries to open the .svg file in Sublime Text. But webbrowser.get('firefox').open() works fine.
After looking closer at this I don't believe it's wise to try to support this directly in leather. In addition to the lack of a reliable cross-platform way to specify a program to open the files, it turns that our that browser file URIs are not universally supported either. There are so many points of failure in this I think it's better to just leave it up to the user to divine the best solution for their particular platform and use case.
I must admit that I'm confused, but I suspect that at least some other potential users would be similarly confused. So I think not addressing this more clearly may be a lapse in the documentation worthy of putting into an issue.
When running the first example at http://leather.readthedocs.io/en/latest/examples.html, everything seems to run properly, but nothing is displayed. And I can't find anything in the docs about how to make it display.
I'm on OS X 10.11.5, running Anaconda's Python 2.7.
Could you please clarify how to make it display? Or maybe, if the problem is just that Anaconda's Python won't work, you could give some clue about what Python distributions are OK?