GithubHelp home page GithubHelp logo

karlwessel / latexwithpgfplots Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 26 KB

Custom Jupyter notebook exporter that can use pgfplots instead of images for plots.

Python 47.29% Smarty 15.17% Julia 37.53%
jupyter-notebook pgfplots julia latex nbconvert

latexwithpgfplots's Introduction

LatexWithPGFPlots

Custom Jupyter notebook exporter that can use pgfplots instead of images for plots.

When using plotting libraries like PGFPlotsX.jl or PGFPlots.jl or their backends in Plots.jl to create plots in a Jupyter notebook this package allows you to use the pgf source code instead of an image of the plot when exporting to LaTeX.

The package consists of two parts:

  1. The julia module LatexWithPGFPlots that adds a custom MIME type "text/pgf" to plots created with PGFPlotsX in a notebook
  2. and the python package latexwithpdf that adds a new exporter for notebooks that uses the pgf source in the exported LaTeX document instead of the image.

You will need to install both.

Installation

Install the exporter with pip by

pip install git+https://github.com/karlwessel/LatexWithPGFPlots.git

Install the julia module from within the REPL with

]add https://github.com/karlwessel/LatexWithPGFPlots.git

Testing

(Re)start jupyter-notebook, create a new julia notebook and add a new cell with

using LatexWithPGFPlots
using PGFPlotsX

p = @pgf Axis(
    {
        xlabel = "Cost",
        ylabel = "Error",
    },
    Plot(
        {
            color = "red",
            mark  = "x"
        },
        Coordinates(
            [
                (2, -2.8559703),
                (3, -3.5301677),
                (4, -4.3050655),
                (5, -5.1413136),
                (6, -6.0322865),
                (7, -6.9675052),
                (8, -7.9377747),
            ]
        ),
    ),
)

Which should show the plot as its used to be.

Now you can try the new exporter by chosing the "LaTeX with pgf plots" exporter from the menue "File -> Download as". Extract the downloaded archive and open the LaTeX source file with your favorite LaTeX editor. You should see that it contains the pgfplots source instead of an includegraphics. You can build the created tex file with xelatex.

You can also use nbconvert from the command line to convert a notebook to LaTeX using jupyter-nbconvert --to=latexwithpgf mynotebook.ipynb

You can also directly download a pdf version by chosing the "PDF via LaTeX with PGF" exporter from the menue "File -> Download as". Note that the compilation of the pdf probably takes much longer than the version without pgf images.

Still missing

  • nothing from my side :)

latexwithpgfplots's People

Contributors

karlwessel avatar

Watchers

 avatar  avatar

Forkers

shanhaiying

latexwithpgfplots's Issues

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.