Comments (6)
@uniele @SgtChrome I have a simple solution for this (which struck me after many days of trial-and-error with different methods) which I will finish implementing this weekend.
@axmonti Yes, I will add that functionality, kindly let me know if you need any more features.
from roughviz.
The feature enhancement has been added in the latest version: V4.7.0
@uniele @SgtChrome Now you can pass the following parameter, which will render the SVG
image (which then can be easily saved/copied):
plot_svg = True
@axmonti I have added the interactive
parameter option as well.
I will close this issue but for any new feature enhancement, kindly open a new issue.
from roughviz.
So far I have tried a couple of ways to save the plots as png.
Consider this example, which creates html code that I saved to test.html.
import roughviz
import pandas as pd
from IPython.display import display, HTML
d = {'col1': [1, 2, 3, 4, 5], 'col2': [3, 4, 10, 2, 0.9]}
df2 = pd.DataFrame(data=d)
data = roughviz.bar(df2["col1"].values, df2["col2"].values)
display(HTML(data.data).data)
If you just wanted to render one or two images, this REST interface does them in high quality, but it's proprietary: https://htmlcsstoimage.com/demo
A solution using wkhtmltoimage failed for me and I wasn't able to figure out why, there might have been some issues with the usage of require...?
import imgkit
config = imgkit.config(wkhtmltoimage='path\to\wkhtmltoimage.exe')
options = {
'format': 'png',
'encoding': "UTF-8",
}
inputfile = 'path\to\test.html'
outputfile = 'path\to\out.png'
imgkit.from_file(inputfile, outputfile, config=config, options=options)
This solution using pyppeteer, which is a python wrapper for puppeteer, worked alright but produced images of lesser quality and scaling them up messed up the formatting of the plot.
import asyncio
from pyppeteer import launch
async def main():
browser = await launch(headless=True)
page = await browser.newPage()
await page.setViewport({'width': 700, 'height': 400})
await page.goto('path\to\test.html')
await page.screenshot({'path': 'path\to\example.png'})
await browser.close()
asyncio.get_event_loop().run_until_complete(main())
I would be very interested in what @hannansatopay were to use.
from roughviz.
Ditto for the awesome work; this is great for capturing people's attention vs. the 'usual' graphs that by now have people glossing over.
This may be a new feature or an add-on to this request, but it would be great if the 'interactive' parameter was passed along in the Python wrapper as well. The issue I'm having is that when the graph is saved as an svg (to, say, insert into PowerPoint), the highlight mask is overlaid and grouped as a large black rectangle that has to be manually removed. I've resorted to creating HTML with the interactive flag set to false and rendering that, but it would be far easier via the Python interface directly.
from roughviz.
@axmonti Would you be willing to share your way of exporting the graph to svg?
from roughviz.
Sure, but will have to 're-create' the script on my personal time, but it's pretty basic...
It's essentially a Python program that iterates through a dataset to create bar graphs for monthly KRI metrics. There are about 25 graphs, so I created a new version of the program that creates a static page on our webserver with the 25 graphs, then run PhantomJS script that iterates through svg images on the page and exports them to individual files to drag into PowerPoint (the svg file is simply the body of each svg element in the rendered webpage). My preference would be to create and export the svg files from Python, or (even better) directly from a native plot save function (as per the initial ask). I initially tried to create the whole script in PhantomJS, but ran into a few scope snags (and ran out of time).
from roughviz.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roughviz.