giovineitalia / compose.jl Goto Github PK
View Code? Open in Web Editor NEWDeclarative vector graphics
Home Page: http://giovineitalia.github.io/Compose.jl/latest/
License: Other
Declarative vector graphics
Home Page: http://giovineitalia.github.io/Compose.jl/latest/
License: Other
I was wondering if there is a way to flip a diagram. Using #96 I was wondering if this would be possible:
flip_along_x = MatrixTransform([
-1 0 1;
0 1 0;
0 0 1.0
])
context(transform=flip_along_x, figure)
This matrix should flip the x value of a point. i.e. 0.3 becomes 0.7, 0.7 becomes 0.3 and so on.
But this approach doesn't seem to work.
Hi, as you mentioned in GiovineItalia/Gadfly.jl#79 you clearly seem to have plans for implementing dashed lines and hopefully other types of lines here, but since I couldn't find an issue about this already and I find this pretty important I thought I'd open a new issue. I think this is a pretty important feature for black and white plots (with different line styles in the same plot) in Gadfly.
@dcjones and @bdeonovic - when drawing a gridstack
result, x-axis tick labels can get cut off if they run past the right-hand-side of the plot region. Here's an example...
using Gadfly
using Compose
p = plot(x=[1,5000,10000], y=[1,2,3], Geom.point)
m = 3
n = 2
cs = Context[render(p) for i in 1:m, j in 1:n]
draw(SVG("temp.svg", 8inch, 8inch), gridstack(cs))
Compose contains using DataFrames
, but doesn't seem to actually use it (or list it in REQUIRES
). Seems to me it does not need it.
It would be convenient to support writing directly to BMP, JPEG, TIFF, etc. I'm guessing the best way to do this would be through Images.jl.
This code probably shouldn't work, but gets parsed as having coordinates (0,0) instead.
draw(SVG(4inch, 4inch), compose(context(), circle(-Inf, NaN, 1)))
The circle is always drawn on the top left corner, even if the units are changed.
draw(SVG(4inch, 4inch), compose(context(units=UnitBox(-5, -5, 5, 5)), circle(Inf, NaN, 1)))
Also, UnitBox
probably shouldn't take nonfinite values.
draw(SVG(4inch, 4inch), compose(context(units=UnitBox(-Inf, -Inf, 1, 1)), circle(Inf, -NaN, 1)))
Hello I'm an experienced R user but new tu Julia. I'm using Windows 8 64-bit and julia-2b22323495
I don't have installed pango or fontconfig and loading fontfallback gives the following error:
ERROR: Missing opening string char
Line: 0
Around: ...{ "Helvetica Neue": {...
^
in error at error.jl:21
in _error at C:\Users\Luciano\AppData\Roaming\julia\packages\JSON\src\Parser.jl
:126
in parse_string at C:\Users\Luciano\AppData\Roaming\julia\packages\JSON\src\Par
ser.jl:229
in parse_object at C:\Users\Luciano\AppData\Roaming\julia\packages\JSON\src\Par
ser.jl:185
in parse_value at C:\Users\Luciano\AppData\Roaming\julia\packages\JSON\src\Pars
er.jl:387
in parse at C:\Users\Luciano\AppData\Roaming\julia\packages\JSON\src\Parser.jl:
477
in parse at C:\Users\Luciano\AppData\Roaming\julia\packages\JSON\src\JSON.jl:10
in include_from_node1 at loading.jl:91 (repeats 2 times)
in reload_path at loading.jl:114
in require at loading.jl:48
at C:\Users\Luciano\AppData\Roaming\julia\packages\Compose\src\fontfallback.jl:6
at C:\Users\Luciano\AppData\Roaming\julia\packages\Compose\src\Compose.jl:48
in anonymous: ccall: could not find function g_type_init in library libpangocairo-1.0
at C:\Users\keithc\AppData\Roaming\julia\packages\Compose\src\pango.jl:46
Possibly related to https://bugs.webkit.org/show_bug.cgi?id=103209?
"g_type_init() is deprecated from 2.35.0 onwards. Don't call it"
Mirroring the SVG properties, allowing for bold, italic, etc.
There used to be a boundingbox
function which was very useful, but I can't seem to find it any more.
Deprecated syntax should be replaced to prevent deprecation warnings on Julia 0.4.
I have a fresh installation of Ubuntu 14.04, with julia version 0.2.1.
I tried to reproduce those magnificent plot from Gadfly demo
using Gadfly
plot(x=rand(10), y=rand(10))
but I get an error (both when run from IPython and Julia terminal)
pangolayout not defined
in text_extents at /home/sasha/.julia/v0.2/Compose/src/pango.jl:103
in text_extents at /home/sasha/.julia/v0.2/Compose/src/pango.jl:120
in render at /home/sasha/.julia/v0.2/Gadfly/src/guide.jl:451
in render_prepared at /home/sasha/.julia/v0.2/Gadfly/src/Gadfly.jl:707
in render at /home/sasha/.julia/v0.2/Gadfly/src/Gadfly.jl:656
in writemime at /home/sasha/.julia/v0.2/Gadfly/src/Gadfly.jl:755
in sprint at io.jl:434
in display_dict at /home/sasha/.julia/v0.2/IJulia/src/execute_request.jl:27
Apparently, c-libraries themselves are installed and Julia bindings are too.
Am I doing something incorrectly?
> Pkg.status()
Required packages:
- Cairo 0.2.13
- Gadfly 0.2.9
- IJulia 0.1.11
- PyPlot 1.2.7
Additional packages:
- BinDeps 0.2.12
- Blocks 0.0.4
- Codecs 0.1.0
- Color 0.2.10
- Compose 0.1.29
- DataArrays 0.0.3
- DataFrames 0.4.3
- DataStructures 0.2.14
- Datetime 0.1.3
- Distance 0.2.6
- Distributions 0.3.0
- GZip 0.2.12
- Hexagons 0.0.1
- Iterators 0.1.2
- JSON 0.3.5
- Loess 0.0.2
- Nettle 0.1.3
- NumericExtensions 0.3.6
- PyCall 0.4.6
- REPLCompletions 0.0.1
- SortingAlgorithms 0.0.1
- StatsBase 0.3.8
- URIParser 0.0.2
- ZMQ 0.1.11
It looks like in SVG to make an arrow you need to define a <marker>
and refer to it with the line.
Is there a way to inject the marker myself? I can then use svgattribute
to point to it
http://iainnz.github.io/packages.julialang.org/
Tests exist, ran 'julia colordiff.jl', failed!
INFO: Installing Color v0.2.8
INFO: Installing Compose v0.1.26
INFO: Installing Iterators v0.1.2
INFO: Package database updated
ERROR: JSON not found
in require at loading.jl:39
in reload_path at loading.jl:144
in _require at loading.jl:59
in require at loading.jl:43
in include_from_node1 at loading.jl:120
while loading /home/idunning/pkgtest/.julia/v0.3/Compose/src/Compose.jl, in expression starting on line 4
while loading /home/idunning/pkgtest/.julia/v0.3/Compose/test/colordiff.jl, in expression starting on line 2
INFO: Package database updated
It would be nice to add writemime
methods for appropriate types to export them to SVG, PNG, HTML with embedded JavaScript, etcetera. Seems like this should be easy to do as thin wrappers around your existing functionality.
The sierpinski example throws a ccall function not found error from pango.jl when
running Version 0.1.2, c4b3649-WINNT-i686 (2013-03-08 11:45:11).
Expanding the lib symbols --
const libpangocairo = symbol("libpangocairo-1.0")
const libpango = symbol("libpango-1.0")
and tweaking the ccall library references resolves the error.
These changes are available at --
https://github.com/catawbasam/Compose.jl/blob/master/src/pango.jl
Currently calling draw(backend, canvas)
uses up the backend, so no more draw operations can occur.
What should happen is that a subsequent draw operation overwrites existing output when possible, and complains if it's not.
using Compose, Interact
points_f = [
(.1, .1),
(.9, .1),
(.9, .2),
(.2, .2),
(.2, .4),
(.6, .4),
(.6, .5),
(.2, .5),
(.2, .9),
(.1, .9),
(.1, .1)
]
f = compose(context(), stroke("black"), line(points_f))
rotate(pic, angle) = compose(context(rotation=Rotation(angle)), pic)
@manipulate for α=0:0.001:pi, θ=0:0.001:pi, ϕ=0:0.001:pi
rotate(rotate(rotate(f, α), θ), ϕ)
end
In this case, α slider rotates the image one complete circle, θ slider rotates the image two complete circles, ϕ slider rotates the image 4 complete circles.
I was expecting each slider to rotate the image half a circle (pi radians), and for the effect of each slider to add up successively. Am I missing something?
After the last update, I am having this issue:
plot(table, xgroup="Parameter", ygroup="Simulation", x="Level", y="Mean", ymin=table[:Mean]-2*table[:Std], ymax=table[:Mean]+2*table[:Std], Geom.subplot_grid(Geom.point, Geom.errorbar))
WARNING: Graphic cannot be correctly drawn at the given size.
Error showing value of type Plot:
ERROR: access to undefined reference
in draw at /Users/tomaskrehlik/.julia/v0.3/Compose/src/form.jl:23
in drawpart at /Users/tomaskrehlik/.julia/v0.3/Compose/src/container.jl:374
in draw at /Users/tomaskrehlik/.julia/v0.3/Compose/src/container.jl:271
in display at /Users/tomaskrehlik/.julia/v0.3/Gadfly/src/Gadfly.jl:885
in display at /Users/tomaskrehlik/.julia/v0.3/Gadfly/src/Gadfly.jl:800
in print_response at REPL.jl:139
in print_response at REPL.jl:124
in anonymous at REPL.jl:551
Simple plots from the documentation plot fine. I am pretty sure that it is some problem with Compose, so I am filing the issue in here.
This doesn't work as I expect. I.e. I want two red circles and two blue circles, but everything is red. In Gadfly this causes error bars to all be drawn the same color regardless of the color aesthetic being mapped.
compose(canvas(unit_box=UnitBox(0, 0, 3, 3)),
combine(circle([1, 2], [1, 2], [0.5, 0.5]),
circle([2, 1], [1, 2], [0.5, 0.5])),
fill([color("red"), color("blue")]))
I'm not actually sure if this is a bug or if this is how it is supposed to work. I'm on the official 0.3.0 release with the latest Pkg.update().
If I run
ys = sin(0:π/12:π/4)
xs = cos(0:π/12:π/4)
compose(context(),line([x::(Float64,Float64) for x in zip(xs,ys)]),stroke(color("tomato")))
compose(context(),curve([x::(Float64,Float64) for x in zip(xs,ys)]...),stroke(color("tomato")))
Then I get images like these for each command:
As you can see, the tomato color is on the curve of line, but it seems to be filled with black for some reason.
PangoAttr
type is defined with Int
but other functions try to assign Int64
. On a 32-bit machine, this causes a problem.
$ ./julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" to list help topics
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.3.0-prerelease+3456 (2014-06-03 22:37 UTC)
_/ |\__'_|_|_|\__'_| | Commit dc53d93* (0 days old master)
|__/ | i686-redhat-linux
julia> versioninfo()
Julia Version 0.3.0-prerelease+3456
Commit dc53d93* (2014-06-03 22:37 UTC)
Platform Info:
System: Linux (i686-redhat-linux)
CPU: Genuine Intel(R) CPU T2250 @ 1.73GHz
WORD_SIZE: 32
BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY)
LAPACK: libopenblas
LIBM: libopenlibm
julia> Pkg.installed("Compose")
v"0.1.29"
julia> using Compose
julia> a = Compose.PangoAttr()
PangoAttr(nothing,nothing,nothing,nothing)
julia> Compose.update_pango_attr(a,:PANGO_ATTR_RISE,3)
ERROR: no method convert(Type{Union(Int32,Nothing)}, Int64)
in update_pango_attr at /home/rick/.julia/v0.3/Compose/src/pango.jl:202
The issues may be here:
From src/pango.jl
.
# A Julia manifestation of a set of pango attributes
type PangoAttr
rise::Maybe(Int)
scale::Maybe(Float64)
style::Maybe(Int)
weight::Maybe(Int)
function PangoAttr()
new(nothing, nothing, nothing, nothing)
end
end
and then further down ...
function update_pango_attr(attr::PangoAttr, attr_name::Symbol, value)
if attr_name == :PANGO_ATTR_RISE
attr.rise = int64(value)
elseif attr_name == :PANGO_ATTR_SCALE
attr.scale = value
elseif attr_name == :PANGO_ATTR_STYLE
attr.style = int64(value)
elseif attr_name == :PANGO_ATTR_WEIGHT
attr.weight = int64(value)
end
attr
end
so, e.g. linecaps.jl doesn't work
I got the following error this morning:
INFO: Upgrading Compose: v0.1.23 => v0.1.24
ERROR: Compose: fetch failed to get commit ec1b17bd69, please file a bug
in fetch at pkg/write.jl:15
in update at pkg/write.jl:36
in resolve at pkg/entry.jl:413
in update at pkg/entry.jl:276
in anonymous at pkg/dir.jl:25
in cd at file.jl:22
in cd at pkg/dir.jl:25
in update at pkg.jl:41
Text doesn't scale with context, but instead is declared via fontsize. It would be fantastic if Compose could automatically figure out the right fontsize. Basically what I wanted to do was draw some text inside a circle, which seems fairly hard to do in the current scheme of things.
In line 381: emitter(emitable.mime, emitable.data)
should be
emitter(emitable.data)
.
as of JuliaLang/julia@d5b5a1f:
WARNING: deprecated syntax "x[i:]" at /Users/jiahao/.julia/Compose/src/cairo_backends.jl:380.
Use "x[i:end]" instead.
(repeats a few more times)
It seems that the following was intended to work:
u = 16
lines = [line([(0.5,0.6),((1+(i-1)/sqrt(u))*0.5w,0.7w)]) for i=1:sqrt(u)]
compose(context(),lines,linewidth(0.1mm),stroke("black"))
It fails with:
`compose` has no method matching compose(::Form{LinePrimitive}, ::Form{LinePrimitive}, ::Form{LinePrimitive}, ::Form{LinePrimitive})
while loading In[43], in expression starting on line 1
in compose at /Users/kfischer/.julia/Compose/src/container.jl:253
The following works though:
compose(context(),lines...,linewidth(0.1mm),stroke("black"))
Hi,
In src/uitl.jl line 57 tries to open a browser window with command run(start $filename
). This does not work as there is no executable by the name start.
I tried with run($(ENV["COMSPEC"]) /c start $(filename)
) and this was working for me.
Regards,
Dinu
I'm playing around with Gadfly, but having problems running through the example. It looks like a missing file in the repo?
(also, what's the best way to update all Julia packages to their current versions?)
julia> p = plot(iris,
{:x => "Sepal.Length", :y => "Sepal.Width"},
Geom.point)
Warning: Possible conflict in library symbol dgemv_
Warning: Possible conflict in library symbol dgemm_
Error showing value of type Plot:
ERROR: could not open file /Users/rrock/.julia/Compose/src/show.html
in open at io.jl:281
in open at io.jl:301
in emitsvg at /Users/rrock/.julia/Compose/src/Compose.jl:360
in emit at /Users/rrock/.julia/Compose/src/Compose.jl:350
in finish at /Users/rrock/.julia/Compose/src/svg.jl:138
in draw at /Users/rrock/.julia/Compose/src/canvas.jl:281
in repl_show at repl.jl:12
julia> draw(SVG(6inch, 4inch), p)
ERROR: could not open file /Users/rrock/.julia/Compose/src/show.html
in open at io.jl:281
in open at io.jl:301
in emitsvg at /Users/rrock/.julia/Compose/src/Compose.jl:360
in emit at /Users/rrock/.julia/Compose/src/Compose.jl:350
in finish at /Users/rrock/.julia/Compose/src/svg.jl:138
in draw at /Users/rrock/.julia/Compose/src/canvas.jl:281
in draw at /Users/rrock/.julia/Gadfly/src/Gadfly.jl:363
This is with Mac OS 10.8.2, and Julia Commit 06b0667e34 (2013-02-15 11:03:16)
It should be possible to pass size hints to a canvas. This way, a graphic can be rendered at a reasonable size without resorting to trial and error.
The most pressing example: drawn at default size, axis labels on gadfly plots will ofter overlap, needing to be redrawn at a larger size. There's no excuse for that when the graphic is completely declared before being drawn, as it is in compose.
Hi,
is there a simple way to get raw image data?
like:
draw(Image::Backend, p::Plot)::Array{Uint8/RGBA,2}
Thanks,
Simon
Hi,
I think I may have found a bug in Compose when using the D3 backend with a Gadfly plot. MacOSX, Julia-0.2-pre, Gadfly 0.1.5, and Compose 0.1.4.
Steps to reproduce:
julia> p = plot(iris,
x="Sepal.Length", y="Sepal.Width",
Geom.point)
julia> draw(D3(6inch, 4inch), p)
WARNING: Unable to emit data of type Emitable
in emit at /Users/stsiab/.julia/Compose/src/Compose.jl:406
Digging around in the source code, I see that "image/svg+xml" MIME type is added to the 'emitters' Dict at Compose.jl:422. However, inserting a diagnostic print statement into the emit(x::Emitable) function shows the requested MIME type to be "application/javascript".
I notice that the "application/javascript" MIMEtype is set in d3.jl:162. Is this correct?
Cheers,
Chris
Hi, the third example on the documentation page here at composejl.org appears to be broken.
The following commands:
using Compose
comp=compose(context(),
(context(), circle(), fill("bisque")),
(context(), rectangle(), fill("tomato")))
lead to the following error:
ERROR: circle
has no method matching circle()
The example can be fixed by specifying that the call to circle() is from the Compose package:
comp=compose(context(),
(context(), Compose.circle(), fill("bisque")),
(context(), rectangle(), fill("tomato")))
I'm using Julia 0.3.3 on Mac OS 10.10.1.
It would be great if it were possible to force the PGF backend to ignore any fonts in the theme so that the plot would just use whatever fonts are used in the latex document.
It seems like this would just be a matter of forcing img.fontfamily
in the PGF constructor to be nothing
if a flag is set, but I couldn't quite figure out where it gets set to something else. I could have a try at implementing this myself with some help.
Thank you for reimplementing gridstack
. In using it, I am getting the following warning with draw
:
WARNING: Graphic cannot be correctly drawn at the given size.
MethodError(getindex,(nothing,1))
Here is a toy example to reproduce the issue...
using Gadfly
using Compose
p = plot(x=[1:10], y=[1:10], Geom.point)
m = 3
n = 2
cs = Context[render(p) for i in 1:m, j in 1:n]
draw(SVG(8inch, 8inch), gridstack(cs))
Let me know if there is anything I can do on my end to help.
This code will cause Gadfly to seg-fault, specifically at cairo.jl:save_state:342.
julia> p = plot(data("datasets", "iris"),x="Sepal.Length", y="Sepal.Width", Geom.point);
julia> png = PNG("myplot.png", 7inch, 4inch);
julia> draw(png, p);
julia> draw(png, p);
Segmentation fault: 11
I feel it would make sense to check in canvas.jl:draw:257, whether the backend is "open" (or has already been closed, in this case).
Julia was just updated. Here's my error:
julia> load("Compose")
invalid redefinition of constant Unit
in load_now at util.jl:235
in load_now at util.jl:235
in load_now at util.jl:235
in load_now at util.jl:235
in load_now at util.jl:235
in load_now at util.jl:235
in load_now at util.jl:247
at /home/tshort/.julia/Compose/src/measure.jl:12
This one is odd, so there might be something fishy with my setup. I cannot find other instances of a constant "Unit" anywhere.
radians2degrees
is now deprecated in 0.3-pre, so running using Compose
throws those deprecation warnings.
The following two snippets render the same way
draw(PNG(40, 40),
compose(context(),
compose(context(), rectangle(0.0, 0.0, 1.0, 1.0), fill(nothing), stroke("black")),
text(0.5, 0.5, "Hello World", hleft, vtop),
compose(context(), circle(0.5, 0.5, 0.01), fill(color("red"))),
fontsize(.5cm)
)
)
draw(PNG(40, 40),
compose(context(),
compose(context(), rectangle(0.0, 0.0, 1.0, 1.0), fill(nothing), stroke("black")),
text(0.5, 0.5, "Hello World", hleft, vbottom),
compose(context(), circle(0.5, 0.5, 0.01), fill(color("red"))),
fontsize(.5cm)
)
)
vtop
and vbottom
behave as expected when the horizontal alignment is center or right
Hi @dcjones. Thank you for reinstating gridstack and for the pull. I'm working on merging it in, but am getting the following error with draw/gridstack:
WARNING: Graphic cannot be correctly drawn at the given size.
MethodError(getindex,(nothing,1))
Here is a toy example to reproduce the issue...
using Gadfly
using Compose
p = plot(x=[1:10], y=[1:10], Geom.point)
m = 3
n = 2
cs = Context[render(p) for i in 1:m, j in 1:n]
draw(SVG(8inch, 8inch), gridstack(cs))
Let us know if there is anything we can do on our end to help.
This issue is being filed by a script, but if you reply, I will see it.
PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their test (if available) on both the stable version of Julia (0.2) and the nightly build of the unstable version (0.3).
The results of this script are used to generate a package listing enhanced with testing results.
The status of this package, Compose, on...
'No tests, but package loads.' can be due to their being no tests (you should write some if you can!) but can also be due to PackageEvaluator not being able to find your tests. Consider adding a test/runtests.jl
file.
'Package doesn't load.' is the worst-case scenario. Sometimes this arises because your package doesn't have BinDeps support, or needs something that can't be installed with BinDeps. If this is the case for your package, please file an issue and an exception can be made so your package will not be tested.
This automatically filed issue is a one-off message. Starting soon, issues will only be filed when the testing status of your package changes in a negative direction (gets worse). If you'd like to opt-out of these status-change messages, reply to this message.
Just updated to Compose 0.3.0 and noticed
Warning: could not import Compose.Canvas into Mamba
Warning: could not import Compose.canvas into Mamba
Warning: could not import Compose.gridstack into Mamba
We (https://github.com/brian-j-smith/Mamba.jl) were using these elements to tweak the MCMC plots (we make a grid of plots that the user can cycle through).
Can you make these available again, or propose another workaround?
It would be convenient to be able to display canvases in the notebook directly, without explicitly making an SVG surface first.
When displaying polygons via writemime (e.g. in IJulia), it would be great if they could automatically get the minimum bounding rectangle as the bounding box.
The requires
file for the commit 699eecd in the METADATA does not match the REQUIRES
file in the package (it is missing Iterators
and Cairo
).
cc: @JeffBezanson
I think GiovineItalia/Gadfly.jl#520 should start off with a 3D Compose API.
Rough plan could be:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.