svg diagrams using python - python

I am looking for a library to generate svg diagrams in python (I fetch data from a sql database). I have found python-gd, but it has not much documentation and last update was in 2005 so I wonder if there are any other libraries that are good for this purpose.
I am mostly thinking about simple line graphs, something like this:

Try using matplotlib. You can configure it with a SVG backend.

As you're looking for simple line graphics, probably, CairoPlot will fit your needs as it can generate svg output files out of the box. Take a look at this.
This example image shows only a few of its capabilities. Using the trunk version available at launchpad you'll be able to add a legend box and add axis titles.
Besides that, using the trunk version, it's possible to generate:
DotLine charts (the ones I believe you need)
Scatter charts
Pie/Donut charts
Horizontal/Vertical Bar charts
Gantt charts

pyCairo is an option worth looking at.

PyChart "is a Python library for creating high quality Encapsulated Postscript, PDF, PNG, or SVG charts."

Here's a general purpose SVG library in Python: pySVG.

You can use Graphviz to generate diagrams in SVG format. There are Python bindings to Graphviz e.g., pydot -- Python interface to Graphviz's Dot language.

Consider svgwrite https://pypi.org/project/svgwrite, a Python package to create SVG drawings.

svgfig is worth a look:
http://code.google.com/p/svgfig/

Being not exactly related to SVG plots, but searching for the same thing I have found a good source of carefully collected useful info to answer your question:
http://wiki.python.org/moin/NumericAndScientific/Plotting

I have tried to collate a list of available charting libraries(its an ongoing work, wherein i keep updating the list) : http://blizzardzblogs.blogspot.com/2010/12/data-visualization-charts-and.html
I feel that protovis would do the job for you. Its
light weight,
generates svg (which can be exported easily) and
is javascript
So nothing more to learn :)

2018 Update:
Plotly ( https://github.com/plotly/plotly.py / https://plot.ly/d3-js-for-python-and-pandas-charts/ ) is probably the most versatile solution. It is distributed under MIT license (free to use and reuse), although it include features that might not be compatible with some CMS with more restrictive security issues since it relies on JS, although options to export the diagrams as plain SVG are also available.
Pygal ( https://github.com/Kozea/pygal / http://pygal.org ) is simpler relies only on svg standard. As such it's results are more reusable under more restrict CMS systems. It is distributed under GNU license.

Related

How to create own font with emojis included (Maybe with Fontforge, Python)?

I want to create my own .ttf font.
It should contains emojis.
I have some Images (emojis) and I want to put these in a new font (I don't want to edit an existing font and I don't have an empty .ttf template).
I googled and found out that it is possible with python (I am happy about this because Python is my favorite programming language and, in my opinion, I am good in it) and fontforge.
I already installed fontforge but I can't import it in python.
and I don't know how to continue after Import.
can someone give me an example please.
or do you know another way to do this, It don't have to be python and fontforge.
but please with example.
Thank you soooo much 🤗
Since you like using Python, FontTools might be useful for you. See https://fonttools.readthedocs.io/en/latest/colorLib/index.html for documentation regarding building fonts with a COLR table. Also, https://github.com/googlefonts/picosvg and https://github.com/googlefonts/nanoemoji might be of interest.
You didn't actually mention which colour format you want to use for your emoji: bitmaps (CBDT or sbix tables), layered outlines (COLR/CPAL tables), or embedded SVG documents (SVG table)>. I know the above will work for COLR/CPAL; not sure about CBDT, sbix or SVG.

Generate dynamic plots with python

I am working on generating some plots using python, but I am generating these plots using matplotlib which is saved as images. If I create an html page as a report with these plots, they are static images. I cannot zoom in or roll over on the plot to see more detailed or specific information on a time series plot.
My question is how can I make these plots dynamic? Can someone suggest the best way to get started and move forward from there?
You should use some additional libraries to achive your goal.
For example, there some good Python web frameworks wich you can use:
CherryPy - allows you to simply write web-app with Python and you can import your plot there.
Plotly Python API - it would simply generate interactive plot, but store it at Plotly platform, but they provide embeded-code option, so you can use it on your site.
I would suggest Plotly, because it is much simpler, but it depends on your needs.
You will definitely want to do it using javascript. It's by far your best option when it comes to quickly make interactive graphs that you can present to a lot of users. Any of these js libraries will do a great job.
You will then want python to provide the data. Depending on the js library you are using, you might be able to parse data from .json, .csv, etc...
If you don't need the data that makes up your plots to change (with user input, for example), then generating and saving flat files with python and having javascript parsing them from some directory might be just enough.
Otherwise, you want to take a look at a python web framework and use one as backend to serve the plots data by request (in that case .json is probably the right format).
Frameworks like Flask, CherryPy, Pyramid or even web2py might be the easier ones to start with.

Basic shape file display using PyQt

Are there any packages that allow for the interactive display of GIS shapefiles? I'm looking to create a simple GUI that displays simple shapefiles (coastlines, etc) but can't seem to find where to start. I was originally tasked with doing this in R but I would like to try and use python and Qt.
Mapnik supports GIS shape files and has a Python interface.
I think you can use a combination of the shapefile library for reading files, and shapely for all the processing of the data.
I have used shapely for working with geo data feeds that have been loaded into a database, to work with the point and polygon data.
Per your comments, if you just want to simply display a shapefile in your PyQt app, then really all you need is to convert it to an SVG and display it directly. I have not used this conversion lib but I am sure there are more like it. Then you can just use a QSvgWidget to load and display it

Cross-platform help viewer with search functionality

I am looking for a help viewer like Windows CHM that basically provides support for
adding content in HTML format
define Table of Contents
decent search
It should work on Windows, Mac and Linux. Bonus points for also having support for generating a "plain HTML/javascript" version that can be viewed in any browser (albeit without search support).
Language preference: Python
wxHtmlHelpController, which is part of wxWidgets, is a cross-platform viewer for HtmlHelp.
I'm not sure how easy it is to use it from a non-wxWidgets program, but I think it can be done.
wxHtmlHelpController doesn't support any scripting within pages, nor does it support css.

Charts in django Web Applications

I want to Embed a chart in a Web Application developed using django.
I have come across Google charts API, ReportLab, PyChart, MatPlotLib and ChartDirector
I want to do it in the server side rather than send the AJAX request to Google chart APIs, as I also want to embed the chart into the PDF.
Which is the best option to use, and what are the relative merits and demerits of one over the other.
Another choice is CairoPlot.
We picked matplotlib over the others for some serious graphing inside one of our django apps, primarily because it was the only one that gave us exactly the kind of control we needed.
Performance generating PNG's was fine for us but... it was a highly specialized app with less than 10 logins a day.
Well, I'm involved in an open source project, Djime, that uses OpenFlashChart 2.
As you can see from our code, generating the JSON-data that OFC uses is a bit complex, but the output is very nice and user friendly, since you can add tooltips, etc. to the different elements.
Open Flash Chart 2
http://teethgrinder.co.uk/open-flash-chart-2/
python library http://btbytes.github.com/pyofc2/
kybi
One package I've wanted to try is graphite. It's a graphing server / platform built with Django. It's specialized for "numeric time-series data" though, like stock prices or bandwidth utilization. If that fits your need I would check it out. Here are some screenshots:
http://graphite.wikidot.com/screen-shots
I like client side charts because you can get full page plotting.
A good options seems to be Jquery Flot : http://code.google.com/p/flot/ which can load JSON data.
However, you won't get pdf support.
Perhaps you might want to have a look here: Django Plotting app.
The HowTo describes how to embed matplotlib plots into the admin interface and create a PDF view.
I have used FusionCharts Free with Django.
Its flash based, open source, multi-licensed and it's well documented. It's ActionScript 1, but AS version wasn't really a criteria for me, though it could be for others.

Categories

Resources