Giter Club home page Giter Club logo

pgfplotsx.jl's Introduction

logo

PGFPlotsX

Documentation Build Status
build codecov

PGFPlotsX is a Julia package to generate publication quality figures using the LaTeX library PGFPlots.

It is similar in spirit to the package PGFPlots.jl but it tries to have a very close mapping to the PGFPlots API as well as minimize the number of dependencies. The fact that the syntax is similar to the TeX version means that examples from Stack Overflow and the PGFPlots manual can easily be incorporated in the Julia code.

Features include:

  • Showing figures inline in Jupyter notebooks, VSCode-julia. Both png- and svg-figures can be shown.
  • Exporting to tex, pdf, svg, and png, file formats.
  • Customizing the preamble so that commands from latex packages can be used.
  • Extra functionality when different packages are loaded, for example Colors, DataFrames, Contour etc.

Installation

The package is registered in the general registry and so can be installed with Pkg.add.

julia> Pkg.add("PGFPlotsX")

Authors

pgfplotsx.jl's People

Contributors

asinghvi17 avatar beastyblacksmith avatar ciaranomara avatar dawbarton avatar dilumaluthge avatar eljungsk avatar femtocleaner[bot] avatar francescoalemanno avatar fredrikekre avatar github-actions[bot] avatar gustaphe avatar iblislin avatar jbrea avatar jebej avatar juliatagbot avatar keitanakamura avatar kristofferc avatar matfi avatar mattiasvillani avatar mgkuhn avatar musvaage avatar o01eg avatar pfitzseb avatar sleort avatar t-bltg avatar tamasgal avatar tkelman avatar tpapp avatar yakir12 avatar zhiyuanzhai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pgfplotsx.jl's Issues

Plan for new release

Many improvements have gone in. We should probably start thinking about a new release. Thoughts on that @tpapp?

I think we should try to have a few more examples, and perhaps extend the documentation a bit. It is also probably not worth keeping backward compatibility so we should warn about that to users, perhaps using the "build-trick".

Test failing on Julia 1.0

Just wanted to get this out here:

WARNING: could not import Base.start into Contour
WARNING: could not import Base.next into Contour
WARNING: could not import Base.done into Contour
ERROR: LoadError: UndefVarError: start not defined
Stacktrace:
 [1] getproperty(::Module, ::Symbol) at ./sysimg.jl:13
 [2] top-level scope at none:0
 [3] include at ./boot.jl:317 [inlined]
 [4] include_relative(::Module, ::String) at ./loading.jl:1038
 [5] include(::Module, ::String) at ./sysimg.jl:29
 [6] top-level scope at none:2
 [7] eval at ./boot.jl:319 [inlined]
 [8] eval(::Expr) at ./client.jl:389
 [9] top-level scope at ./none:3
in expression starting at /Users/arora/.julia/packages/LaTeXStrings/qycAf/src/LaTeXStrings.jl:62
ERROR: LoadError: Failed to precompile LaTeXStrings [b964fa9f-0449-5b57-a5c2-d3ea65f4040f] to /Users/arora/.julia/compiled/v1.0/LaTeXStrings/H4HGh.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] macro expansion at ./logging.jl:313 [inlined]
 [3] compilecache(::Base.PkgId, ::String) at ./loading.jl:1184
 [4] macro expansion at ./logging.jl:311 [inlined]
 [5] _require(::Base.PkgId) at ./loading.jl:941
 [6] require(::Base.PkgId) at ./loading.jl:852
 [7] macro expansion at ./logging.jl:311 [inlined]
 [8] require(::Module, ::Symbol) at ./loading.jl:834
 [9] include at ./boot.jl:317 [inlined]
 [10] include_relative(::Module, ::String) at ./loading.jl:1038
 [11] include(::Module, ::String) at ./sysimg.jl:29
 [12] include(::String) at ./client.jl:388
 [13] top-level scope at none:0
in expression starting at /Users/arora/.julia/packages/PGFPlotsX/aBnwE/test/runtests.jl:7
ERROR: Package PGFPlotsX errored during testing

Support plotting surface data

This would require a method for Coordinates that takes x,y, and z where z is a matrix such that size(z,1)==length(x) and size(z,2)==length(y)

xticklabel in PGFPlotsX

I am creating a polar axis, but I want my x value, all shift 90 degree, so I write

 xticklabel={
         $\pgfmathparse{ Mod((270+\tick),360)}\pgfmathprintnumber{\pgfmathresult} $
            
            }

but in notebook it is shown that

syntax: "\" is not a unary operator

there is someone can tell me where is the problem. Thanks a lot

No support of Julia v0.5.2?

julia> Pkg.add("PGFPlotsX")
------ CompositeException -------------- Stacktrace (most recent call last)

 [1] — add(::String) at pkg.jl:100

 [2] — #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, ::Vararg{Any,N}) at dir.jl:31

 [3] — cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#add,Tuple{String}}, ::String) at file.jl:59

 [4] — (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#add,Tuple{String}})() at dir.jl:31

 [5] — add(::String, ::Base.Pkg.Types.VersionSet) at entry.jl:51

 [6] — macro expansion at task.jl:327 [inlined]

 [7] — sync_end() at task.jl:311

PGFPlotsX can't be installed because it has no versions that support 0.5.2 of julia. You may need to update METADATA by running `Pkg.update()`
 in resolve(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{String,Tuple{VersionNumber,Bool}}, ::Dict{String,Base.Pkg.Types.Fixed}, ::Dict{String,VersionNumber}, ::Set{String}) at entry.jl:482
 in edit(::Function, ::String, ::Base.Pkg.Types.VersionSet, ::Vararg{Base.Pkg.Types.VersionSet,N}) at entry.jl:30
 in (::Base.Pkg.Entry.##2#5{String,Base.Pkg.Types.VersionSet})() at task.jl:360

Exporting underscore

I am using math mode in axis description in group plot like:

julia> @pgf gp = pgf.GroupPlot()
julia> push(gp,@pgf {"ylabel = {\$P\_{\\mathrm{Err}}\$}"})
julia> PGFPlotsX.print_tex(gp)

\begin{groupplot}[]
    \nextgroupplot[ylabel = {$P {\mathrm{Err}}$}]
\end{groupplot}

But the underscore is not exported. Is it a bug or intended behaviour?

Thanks for an answer.

reading coordinates from external datasets

When I try to read data from an external file, I do it like

julia> ofile = "test.tex";
julia> PGFPlotsX.print_tex(@pgf Table({meta => "tsterr"},ofile))
table[meta={tsterr}]
{
    test.tex
}

which issues an error. If I manually change the output to

table[meta={tsterr}]
{test.tex}

Then it works flawlessly. Is it possible to remove new lines?

Thanks for help.

"exporting" save

In the spirit of #62, it would be nice if PGFPlotsX.save would just work with less typing (or workarounds, like const something = ...). It is of course too generic to export as is. I was thinking of two alternatives:

  1. rename it, eg pgfsave,

  2. integrate it into a general mechanism like FileIO.jl

WARNING: Error requiring Juno from PGFPlotsX: ArgumentError: Module Hiccup not found in current path.

Running

Pkg.add("PGFPlotsX")

on a Ubuntu 18.04 server and julia 0.6.4, I get the error

WARNING: Error requiring Juno from PGFPlotsX:
ArgumentError: Module Hiccup not found in current path.
Run `Pkg.add("Hiccup")` to install the Hiccup package.
Stacktrace:
 [1] _require(::Symbol) at ./loading.jl:435
 [2] require(::Symbol) at ./loading.jl:405
 [3] err(::PGFPlotsX.##64#71, ::Module, ::String) at /root/.julia/v0.6/Requires/src/require.jl:44
 [4] withpath(::PGFPlotsX.##63#70, ::String) at /root/.julia/v0.6/Requires/src/require.jl:34
 [5] (::PGFPlotsX.##62#69)() at /root/.julia/v0.6/Requires/src/require.jl:56
 [6] _collect(::Array{Function,1}, ::Base.Generator{Array{Function,1},Requires.##3#4}, ::Base.EltypeUnknown, ::Base.HasShape) at ./array.jl:483
 [7] loadmod(::Symbol) at /root/.julia/v0.6/Requires/src/require.jl:22
 [8] require(::Symbol) at ./loading.jl:408
 [9] _include_from_serialized(::String) at ./loading.jl:157
 [10] _require_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:200
 [11] _require(::Symbol) at ./loading.jl:498
 [12] require(::Symbol) at ./loading.jl:405
 [13] include_from_node1(::String) at ./loading.jl:576
 [14] include(::String) at ./sysimg.jl:14
 [15] process_options(::Base.JLOptions) at ./client.jl:305
 [16] _start() at ./client.jl:371

don't try to show empty `TikzDocument()`

This comes up when running examples in the manual line by line, eg

td = TikzDocument()

will create an empty (0-byte) PDF file. show will call eg xdg-open on it, which (on my Linux machine) calls a text editor.

We could catch this in show, eg test for

(!(p isa TikzDocument) || isempty(p.elements))

or something like this.

use Docker images for CI (WIP)

In order to cope with the terminated CI builds, I am exploring using a docker image for CI. It is based on this definition. The stable Julia binary is built into the image, and so are the necessary TeXLive files. Nightly is downloaded when run.

WIP:

  • test locally
  • make it run on on Travis (for some reason the build is not triggered)
  • check Travis output
  • extract coverage information (should be copied out from the image into the mounted directory when run)

use \\ as row sep by default

I was running into some "fragility" corner cases today with tikzscale + \tikzexternalize + pgfplots, which were solved by using \\ as the row sep in TableData. This made me wonder if we should always use row sep=\\ and generate data accordingly by default. I can't see any drawbacks to this. Would make a couple of examples, especially the patch one, simpler.

vertical/horizontal line

(opening the issue for discussion before making a PR)

I am wondering if it would make sense to introduce types that emit code for vertical or horizontal lines, eg
VerticalLine([options], x) would print_tex

\draw[options] (x,\pgfkeysvalueof{/pgfplots/ymin})--(x,\pgfkeysvalueof{/pgfplots/ymax});

for use withing Axis & friends. Similarly for HorizontalLine.

Improve documentation

Put the examples from the separate repo into the documentation instead.
Use @example from Documenter to generate example figures inline.

Don't have to worry about repo size because we can just nuke the gh-pages branch whenever we want.

Also:

  • : Add docs for Legend.

Table Reading Problem

Hi, I have a probolem about the data using. I want to plot the data in the table, then I use my data .dat file ,the data is in the following:

1 1.0957924e+01
2 1.1014873e+01
3 1.1071216e+01
4 1.1126760e+01
5 1.1181310e+01
.
.
.
but after running it, it shows this comment:

! Package pgfplots Error: Sorry, the requested column number '1' in table do not exist?

why this problem happened ? can anyone help? Thanks

feature request: custom labels for contour lines

Is there a way I could have custom labels, eg strings, on the contour lines, instead of the z values? I need them for some highest density region plots. MWE (not with HDR plots, just a graph):

using Contour
using PGFPlotsX: Plot, Table

x = linspace(0, 1, 50)
z = .√((x .- 0.5).^2 .+ (x' .- 0.5).^2)
# I would like to have the strings ["5%", "25%", "50%", "75%", "95%"] on the contour lines
Plot(Table(contours(x, x, z, 5)), "contour prepared", "thick"; incremental = false)

feature request: extensions recognized by tikzscale

tikzscale allows LaTeX to load Tikz/PGF graphics with

\includegraphics[width=0.5\linewidth]{some_path.tikz}

This is handy for scaling, also for using the same mechanism for including all graphics.

It recognizes extensions .tikz, .TIKZ, .TikZ, .pgf, .PGF. It would be nice to have PGFPlotX.save pick the tex backend for these extensions (without the preamble by default).

RFC: grand constructor unification

Grand constructor unification

This addresses #11, #16, #37, and continues #43.

Objectives

  1. Consistent constructors of the form Type([options], ...) where ... include various convenience forms. Easier to remember, more consistent with the LaTeX code of pgfplots.

  2. Optionally, shorten some struct/constructor names. The expectation is that the user uses pgf. for the module. This is an optional part of the RFC, and the refactoring can be done without it.

  3. Make constructors validate whatever possible (eg dimension consistency etc), to fail early.

Remark: in order to make this writeup more compact, Vector and Matrix stand-in for their abstract counterparts below. The functions should always accept everything.

Specifics

Whenever we have options, it becomes the first field of the struct.

TikzDocument

Rename to Document. Constructor is TikzDocument([elements]; preamble).

TikzDocument(elements::Vector; preamble) is deprecated.

TikzDocument(element) and TikzDocument(; preamble) survive as special cases.

TikzPicture

Rename to Picture. The constructor is TikzPicture([options], elements...).

TikzPicture(elements::Vector, options), TikzPicture(options, elements), and TikzPicture(elements::Vector) are deprecated. TikzPicture(options) remains as a special case.

Axis

The constructor is Axis([options], plots...).

Axis(plots::Vector, options), Axis(plot, options...) are deprecated.

Very similarly: PolarAxis, also introduce SemiLogXAxis, SemiLogYAxis, LogLogAxis.

Plot, Plot3

Introduce Plot([incremental], [options], elements...).

Plot(elements::Vector, options), Plot(elements:Vector, options...), and forms with label are removed.

legend was used for \addlegendentry. But this can be specified alternatively:

  1. with a Legend type which would emit \legend (does not exist currently)
  2. with a LegendEntry type which would emit \addlegendentry (similarly, does not currently exist)
  3. with the legend entries option for Axis.

Furthermore, Section 4.9.4 of the manual says that

It does not matter where \addlegendentry commands are placed, only the sequence matters.

so there is no strong reason to have it in Plot.

Very similarly for Plot3.

Coordinates

Coordinates(coords::Matrix, [error::Matrix], [meta::Vector]) is the single inner constructor. It checks that coords and error have the same size (if applicable), with 2 or 3 columns, and that meta has matching length (when provided).

Convenience constructors could include:

  • Coordinates(x::Vector, y::Vector; [xerror::Vector, yerror::Vector], [meta::Vector]). When an error is given but another is not, the first error is filled with zeros.

  • Coordinates(x::Vector, y::Vector, z::Vector; [meta::Vector]) (I don't think 3d allows error bars, does it?)

  • Coordinates(y::Vector; [meta::Vector]) which makes x a vector of 1, 2, ... (for simple time series etc).

Convenience feature: when a row of coords is missing, an empty line emitted for LaTeX.

Table

Table(options, contents::Matrix, names::Vector) is the default inner constructor. It verifies consistency of names and contents.

Table([options], ::Pair{Union{Symbol, String}, Vector}...) is the preferred constructor for users. Keys can be defined with symbols and strings (all converted to strings). The constructor verifies that lengths match and that there are no duplicate keys.

Convenience constructors:

  • Table([options], x::Vector, [y::Vector], [z::Vector], [meta::Vector]): the first 4 vectors are names x, y, z, and meta automatically when unnamed.

  • Existing converting convenience constructors are kept (eg for StatsBase.Histogram, Contour).

Convenience feature: when any element of a row is missing, an empty line is printed in LaTeX.

Graphics

We keep Graphics([options], filename).

GroupPlot

The new constructor is GroupPlot([options], contents::Matrix).

The group size option is inferred from the dimensions of contents automatically and overwrites any existing option.

contents can have the following elements:

  • a Plot, which is emitted as is with a \nextgroupplot

  • an Axis containing Plots: its options are appended to \nextgroupplot, then the plots are emitted,

  • a missing value: just a \nextgroupplot.

Expression

Unchanged.

Open questions

  1. Should we have a Coordinates3 type separately for 3d coordinates? Does not exist in pgfplots, but the code would be cleaner (I don't think they take error bars, and Plot3 could refuse to accept 2d Coordinates, etc).

  2. Should "key", :key, "key" => value, and :key => value be accepted as a stand-in for options, converting automatically? Advantage: shorter code when using a single option, though using @pgf is not much more verbose. Disadvantage: the constructor for Table would need to disentangle this case, which may be difficult. I would prefer not to do this.

  3. Should we have a Legend and LegendEntry?

Implementation roadmap

  1. Replace type and constructors one by one, to make review easier.

    a. each one gets documented,
    b. unit tests with 100% coverage for new forms,
    c. deprecations are introduced for older forms.

  2. Documentation, including examples, are rewritten extensively.

  3. Release is tagged.

  4. Deprecated forms removed in next release.

different mesh levels

Hi, I am trying to make a plot where I can adjust the amount of data points (markers) that I show. I want to do this so that I can have a course grid on a large scale, then in a zoomed in part of the graph have a finer mesh. Is this possible?

I looked through the PGF documentation and saw options for adjusting the mesh grid in a 3 D plot ( I am just trying to do a 2D plot). Something like mesh/row and mesh/column on page 258
http://pgfplots.sourceforge.net/pgfplots_unstable.pdf

I also saw an option to set the number of points, with an option called samples, but I get an error when I try to use it.

Thanks !

export interface

The vocabulary of the package is remarkably sparse, mostly because pgfplots is, and the @pgf macro. Exporting it would make interactive use easier and simplify the manual and the examples. Eg

export
    Axis, Plot, Plot3, TikzPicture, TikzDocument, Table,
    Expression, Coordinates, @pgf, Graphics, GroupPlot, save

would do it (unless I missed something). Users who don't wish to crowd their namespace could still use

import PGFPlotsX

(edit: added save)

suggestion on using tikz output (documentation)

The manual or the README could mention the following:

  1. \pgfplotsset{compat=1.15} is recommended in the preamble for some features used by the emitted Tikz output (LaTeX warns about this),

  2. possibly mention tikzscale as a way of using plots in a flexible manner (cf #23)

NaN and Inf in Coordinates

Starting this issue for discussion of the interface. While working on #58, I learned that pgfplots can handle NaN and Inf values, and discard or jump, with the relevant option being

/pgfplots/unbounded coords=discard|jump

on page 119 of the pgfplots manual.

Table now works fine with these, I also added an example in the gallery.

However, Coordinates rejects non-finite values. Per se this can be fixed easily (by removing the check), but the current semantics of preferred constructors replace these values with empty lines anyway.

I thought of

  1. removing the check, so that if someone insists, they can construct eg
Coordinate((Inf, NaN, -Inf))
  1. but keep the current Coordinates behavior, suggesting that a Table should be used for non-finite values.

This would make it very easy to plot functions with jumps.

Broken link in README

The broken link is in this line

Extra functionality when different packages are loaded

@pgf macro should probably use DataStructures.OrderedDict

Because using PGFPlotsX: @pgf does not bring the module name into scope. MWE:

julia> module Foo
       
       using PGFPlotsX: @pgf
       
       test() = @pgf { ymax = 1 }
       
       end
Foo

julia> Foo.test()
ERROR: UndefVarError: PGFPlotsX not defined
Stacktrace:
 [1] test() at ./REPL[36]:5

Introduce new kwarg "legend"

In accordance with this post I needed to \label a few addplots. To share nomenclature with Plots , I imagine, PGFPlotsX allows to define a \addlegendentry using a label= kwarg in constructing Plot-like objects. However, I recommend that that kwarg be changed to legend= and the behavior of label= be modified, to help people like me.

I have submitted #15 for this reason.

Figure out a way to have the options of an AxisLike object to be close to its constructor name.

Here is an example:

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

The "problem" here is that the options for e.g. the Axis are very far away from the start of the Axis command. In .tex, the options are close to the begin{axis}. Perhaps one should be able to use a keyword argument or dispatch on the type. The problem with dispatching on the type is of course something like Axis("foo", "bar")...

representation of a domain (1:2)

#72 removed a method which accidentally made things like domain = 1:2 work, because for UnitRange{<: Integer} Julia's representation coincides with that of pgfplots. It was removed because this no longer holds for eg 1.2:10.1 (StepRangeLen).

Base has no type for representing intervals as such. We could

  1. leave it as is (user needs to use a string, eg "$a:$b"),
  2. make some existing Base type stand for ranges when handled by print_opt,
  3. introduce a new type in PGFPlotsX,
  4. define print_opt for some type in an existing package, eg IntervalSets.jl

No display on IJulia

I am working on Julia v1.0 (this might be the issue). While trying to display my PGFPlotsX,

using PGFPlotsX Plot(Table([x, y]))

only outputs the Plot object

Plot(false, false, PGFPlotsX.Options(DataStructures.OrderedDict{Any,Any}(), false), Table(PGFPlotsX.Options(DataStructures.OrderedDict{Any,Any}(), false), TableData([0.0 0.0; 0.0634665 0.0634239; … ; 6.21972 -0.0634239; 6.28319 -2.44929e-16], nothing, Int64[], true)), Any[])

Any thoughts?

BTW - I tried using display(Plot(Table([x, y]))) but it seems to open a pdf application.

Thanks!

Snir

row sep in tables.

The PGFPlots gallery has the following example:

\begin{tikzpicture}
	\begin{axis}
	\addplot[patch,table/row sep=\\,patch table={%
		0 1 2\\
		1 2 3\\
		4 3 5\\
	}]
	table[row sep=\\,point meta=\thisrow{c}] {
		x y c  \\
		0 0 0.2\\% 0
		1 1 0  \\% 1
		2 0 1  \\% 2
		3 1 0  \\% 3
		2 0 0.5\\% 4
		4 0 0.5\\% 5
	};
	\end{axis}
\end{tikzpicture}

I'm not sure we can replicate that since we need to be able to end each table row with \\.

save multiple formats

Currently the generation of formats works like this:

julia --0--> tex --1--> pdf --2--> svg
                         |
                         +----3--> png

It is my impression that (1) is relatively expensive, while (2) and (3) are cheap, and (0) is trivial for runtime.

It would be nice to have a user interface that just keeps the interim files if the user asks for it. This came up in, eg, #52.

The purpose of this issue is to discuss whether this could be useful, and figure out the interface.

I can imagine two interfaces:

  1. save("something.svg", plot; keep_pdf = true, keep_tex = true)
    Rudiments of this already are in the code. Disadvantages:

    a. the user has to be conscious of the generation paths above,
    b. the "other" format (for svg/png) would still need generation.

    Of course we could expose pdf2svg and similar.

  2. A single interface that figures it all out. I was thinking of either

save("something.tex|pdf|svg", plot)

or

save(("something.tex", :pdf, :svg), plot)

Order of extensions is arbitrary in either, the implementation will figure it out.

Failure to open PDF at REPL on OS X

Under PGFPlotsX 0.1.4 the following code fails:

julia> import PGFPlotsX: Axis, Plot, Plot3, @pgf, PolarAxis, TikzDocument, GroupPlot, TikzPicture,
                         Table, Expression, Coordinates, Graphics

julia> x = [1, 2, 3];

julia> y = [2, 4, 1];

julia> p = Plot(Coordinates(x, y))
Error showing value of type PGFPlotsX.Plot:
ERROR: Failed to show the generated pdf, run `PGFPlotsX.enable_interactive(false) to stop trying to show pdfs.`
Stacktrace:
 [1] show(::IOContext{Base.Terminals.TTYTerminal}, ::MIME{Symbol("text/plain")}, ::PGFPlotsX.Plot) at /Users/spowell/.julia/v0.6/PGFPlotsX/src/tikzdocument.jl:263
 [2] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::PGFPlotsX.Plot) at ./REPL.jl:122
 [3] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::PGFPlotsX.Plot) at ./REPL.jl:125
 [4] display(::PGFPlotsX.Plot) at ./multimedia.jl:194
 [5] eval(::Module, ::Any) at ./boot.jl:235
 [6] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
 [7] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
 [8] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646

However manually executing the relevant contents of the show function seems to work fine (Preview is opened and the plot is displayed):

julia> f = tempname() .* ".pdf"
"/var/folders/n3/d9h7pnvn01qfnb8pqxs2j_yr0000gn/T/juliat8Uzaf.pdf"

julia> PGFPlotsX.save(f,p)

julia> run(`open $f`)

julia>

Any ideas?

handle units (mostly length)

using Unitful: cm
using PGFPlotsX

@pgf Axis({ width = 8cm, height = 7cm }, ...) # not strings but units

All this would need is a print_tex method, conditional on using Unitful (via @require).

Opened the issue for discussion, I will do a PR. Open questions:

  1. is Unitful the units package we should support? I am confused because there are multiple ones.
  2. absolute units like pt and relative units like em or ex are unsupported, should they be submitted as PRs to that package? cm, mm and in are supported.

printing overhaul

A minor rewrite of print_tex & related would probably be beneficial.

I am thinking along the following lines:

  1. Remove 3-argument calls for print_tex. AFAICT currently nothing specializes on the 3rd argument. The type should determine printing.

  2. Explicitly handle some types as "inline" and "block". Eg real numbers are inline, anything that makes newlines is block.

  3. Make indentation based on IOContext.

  4. Containers should indent their contents, not the whole container. not all containers should indent, most importantly above axis, consistently with the manual, eg

\begin{tikzpicture}
\begin{axis}[enlargelimits=false, axis on top]
    \addplot[matrix plot*,
        nodes near coords=\coordindex,mark=*,
        point meta=explicit,
    ] coordinates {
        (0,0) [0] (1,0) [1] (2,0) [2]
        (0,1) [3] (1,1) [4] (2,1) [5]
        (0,2) [6] (1,2) [7] (2,2) [8]
    };
\end{axis}
\end{tikzpicture}

Text annotation (node)

Is there any way to add text annotations using PGFPlotsX?

This would normally be achieved by adding an arbitrary \node to an axis, but I can't see this functionality in the examples.

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.