Giter VIP home page Giter VIP logo

Comments (10)

dcjones avatar dcjones commented on May 22, 2024

Hmm, that's not a bad idea, though copying to the clipboard in a cross-platform way may be a pain.

How best to include plots in documents is something I need to document more thoroughly though.

This may or may not be helpful, but here is a document generation system in Gadfly that is designed to produce documents with a lot of code examples and plots. It works by writing normal markdown:

If you make a file like this.

   # An example
   This is an example of executable markdown.

    ```julia
    using Gadfly
    draw(SVG(4inch, 4inch), plot(sin, 0, 20))
    ```

There is a script that comes with gadfly that will turn this into an html file with all the plots rendered and the julia code syntax highlighted. If you pass it the --self-contained flag, all the the images will be embedded directly in the document using data URIs.

So if you run:

~/.julia/bin/gadfly document.md > document.html

You'll get totally self contained html file with embedded images. This relies on having pandoc installed, though.

from gadfly.jl.

diegozea avatar diegozea commented on May 22, 2024

I get this error:

ERROR: no method *(Cmd,Cmd)
 in execblock_julia at /home/dzea/.julia/Gadfly/src/weave.jl:320
 in weave at /home/dzea/.julia/Gadfly/src/weave.jl:116
 in include_from_node1 at loading.jl:76
 in process_options at client.jl:255
 in _start at client.jl:318
at /home/dzea/.julia/Gadfly/bin/gadfly:75

from gadfly.jl.

diegozea avatar diegozea commented on May 22, 2024

[ Maybe if copy to clipboard is difficult, and I think can be... Using embed() for open the code on the navigator instead of the plot for a easy copy&paste can be an option ? ]

from gadfly.jl.

dcjones avatar dcjones commented on May 22, 2024

Actually that's pretty easy to do. Instead of pointing the browser to the plot, it can use a view-source URI, and point it to view-source:file://some/temporary/file.html which would show the code for the plot that you can then copy and paste. I could add a viewsource function that does that.

But I'm really hesitant to try to do anything with the clipboard directly, it's hard to get right, much less right on multiple platforms.

from gadfly.jl.

diegozea avatar diegozea commented on May 22, 2024

Yes, but I believe that the code source is not exactly the same that is needed for copy&paste between a blog text. I don't have experience with that, so I can be wrong.

from gadfly.jl.

diegozea avatar diegozea commented on May 22, 2024

For example, I copy&paste the <div> of the <body> of the plot into the HTML of my blog post, but I see this:
http://experienciasconjulia.wordpress.com/2013/02/22/10/

from gadfly.jl.

diegozea avatar diegozea commented on May 22, 2024

But... Looks to be a problem between WordPress and the HTM, the same code on Blogger works fine:
http://fisica1unq.blogspot.com.ar/2013/02/example-0.html

What I says about the embed() o source() functions is generate the code without the header. Just ready for copy&paste inside a post or page.

from gadfly.jl.

dcjones avatar dcjones commented on May 22, 2024

Oh, that's interesting.

I found a wordpress bug report about inline svg. It seems they don't support it. So for wordpress, you'll have to save the plot to a file and include it using an <object> tag.

from gadfly.jl.

diegozea avatar diegozea commented on May 22, 2024

Thanks, I think I going to use blogger if I can SyntaxHighligter works on it.
Another similar stuff happens with view on Gmail if you attach the .html output file.
People who receives the mails and click view only see code instead of the plot.

from gadfly.jl.

dcjones avatar dcjones commented on May 22, 2024

I don't think the gmail issue is solvable. It looks like gmail doesn't support sending html email. Even if you send an html document as an attachment, it strips out anything it deems "unsafe", which is any javascript or anything embedded with the <object> tag.

The best option now is to put the plot somewhere and send a link. Once I fix the cairo backend, you'll also be able to send a PDF/PS/PNG file, which gmail might be less suspicious of.

from gadfly.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.