Code Monkey home page Code Monkey logo

gr.jl's Introduction

The GR module for Julia

The MIT License GitHub tag GR Downloads DOI Binder Join the chat at https://gitter.im/jheinen/GR.jl

PkgEval CI Coverage Status

Screenshots

This module provides a Julia interface to GR, a framework for visualisation applications.

Installation

From the Julia REPL an up to date version can be installed with:

julia> using Pkg
julia> Pkg.add("GR")

or in the Pkg REPL-mode:

pkg> add GR

The Julia package manager will download and install a pre-compiled run-time (for your hardware architecture), if the GR software is not already installed in the recommended locations.

Getting started

In Julia simply type using GR and begin calling functions in the GR framework API.

Let's start with a simple example. We generate 10,000 random numbers and create a histogram. The histogram function automatically chooses an appropriate number of bins to cover the range of values in x and show the shape of the underlying distribution.

using GR
histogram(randn(10000))

Using GR as backend for Plots.jl

Plots is a powerful wrapper around other Julia visualization "backends", where GR seems to be one of the favorite ones. To get an impression how complex visualizations may become easier with Plots, take a look at these examples.

Plots is great on its own, but the real power comes from the ecosystem surrounding it. You can find more information here.

Alternatives

Besides GR and Plots there is a nice package called GRUtils which provides a user-friendly interface to the low-level GR subsytem, but in a more "Julian" and modular style. Newcomers are recommended to use this package. A detailed documentation can be found here.

GR and GRUtils are currently still being developed in parallel - but there are plans to merge the two modules in the future.

Run-time environment

GR.jl is a wrapper for the GR Framework. Therefore, the GR run-time libraries are required to use the software. These are provided via the GR_jll.jl package, which is an autogenerated package constructed using BinaryBuilder. This is the default setting.

Another alternative is the use of binaries from GR tarballs, which are provided directly by the GR developers as stand-alone distributions for selected platforms - regardless of the programming language. In this case, only one GR runtime environment is required for different language environments (Julia, Python, C/C++), whose installation path can be specified by the environment variable GRDIR.

ENV["JULIA_DEBUG"] = "GR" # Turn on debug statements for the GR package
ENV["GRDIR"] = "<path of you GR installation>" # e.g. "/usr/local/gr"
using GR

For more information about setting up a local GR installation, see the GR Framework website.

However, if you want to permanently use your own GR run-time, you have to set the environment variable GRDIR accordingly before starting Julia, e.g.

  • macOS or Linux: export GRDIR=/usr/local/gr
  • Windows: set GRDIR=C:\gr

Please note that with the method shown here, GR_jll is not imported.

Switching binaries via GR.GRPreferences

To aid in switching between BinaryBuilder and upstream framework binaries, the GR.GRPReferences module implements three methods use_system_binary(), use_upstream_binary(), and use_jll_binary(). These use Preferences.jl to configure GR.jl and GR_jll.jl.

To use an existing GR install, invoke use_system_binary.

using GR
GR.GRPreferences.use_system_binary("/path/to/gr"; force = true)

To download and switch to upstream binaries invoke use_upstream_binary.

using GR # repeat this if there is an error
GR.GRPreferences.use_upstream_binary(; force = true)

use_system_binary and use_upstream_binary accept an override keyword. This may be set to one of the following:

  • :depot (default) - Use Overrides.toml in the Julia depot. This normally resides in .julia/artifacts/Overrides.toml
  • :project - Use LocalPreferences.toml. This is usually located near the Project.toml of your active project environment.
  • (:depot, :project) - Use both of the override mechanisms above.

To switch back to BinaryBuilder binaries supplied with GR_jll, invoke use_jll_binary:

using GR # repeat this if there is an error
GR.GRPreferences.use_jll_binary(; force = true)

This will reset both the :depot and :project override mechanisms above.

If you encounter difficulties switching between binaries, the diagnostics() function will provide useful information. Please include this information when asking for assistance.

using GR
GR.GRPreferences.diagnostics()

gr.jl's People

Contributors

barche avatar cnliao avatar dalum avatar danielkaiser avatar falobaid avatar florianrhiem avatar fonsp avatar goropikari avatar heliosdrm avatar hessammehr avatar jheinen avatar joshday avatar juliatagbot avatar kojix2 avatar machakann avatar maltedeckers avatar masonprotter avatar mkitti avatar mpastell avatar mtsch avatar pfitzseb avatar simonbyrne avatar sjkelly avatar t-bltg avatar thoappelsin avatar tkelman avatar tomaklutfu avatar v-i-s-h avatar ven-k avatar wheeheee 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  avatar  avatar  avatar  avatar

gr.jl's Issues

Trisurf support for triangles

It would be nice to be able to set the triangles in trisurf. For example, and array triangles is usually given as:

triangles = [node1 node2 node3
                   node4 node5 node6
                   ...]

where this means that for

plot(x,y,z,triangles=triangles)

we have that (x[node1],y[node1],z[node1]), (x[node2],y[node2],z[node2]), and (x[node3],y[node3],z[node3]) are the points which make the first triangle, etc. The reason for this is referenced in JuliaPlots/Plots.jl#392

GR3 doesn't work with the default installation.

Hi,

First of all, I'm very excited with this visualization framework! I think this is a really great work.

But I encountered a problem when I tried to run a 3D example script:

~/.j/v/G/examples ((v0.9.14)|✔) $ julia spin.jl
ERROR: LoadError: error compiling setbackgroundcolor: could not load library "/Users/kenta/.julia/v0.4/GR/deps/gr/lib/libGR3.so"
dlopen(/Users/kenta/.julia/v0.4/GR/deps/gr/lib/libGR3.so, 1): Library not loaded: /usr/local/gr/lib/libGR.so
  Referenced from: /Users/kenta/.julia/v0.4/GR/deps/gr/lib/libGR3.so
  Reason: image not found
 in include at /usr/local/julia/v0.4/lib/julia/sys.dylib
 in include_from_node1 at /usr/local/julia/v0.4/lib/julia/sys.dylib
 in process_options at /usr/local/julia/v0.4/lib/julia/sys.dylib
 in _start at /usr/local/julia/v0.4/lib/julia/sys.dylib
while loading /Users/kenta/.julia/v0.4/GR/examples/spin.jl, in expression starting on line 47
~/.j/v/G/examples ((v0.9.14)|✔) $

The libGR3.so library tried to load /usr/local/gr/lib/libGR.so, but it does not exist at the location.
I installed this package using Pkg.add("GR") without pre-install of the GR framework.
Since the library path is already included in the libGR3.so, I think you should reconsider the way to distribute this package:

~/.j/v/G/d/g/lib ((v0.9.14)|✔) $ otool -L libGR3.so
libGR3.so:
        /usr/local/gr/lib/libGR3.so (compatibility version 0.0.0, current version 0.0.0)
        /usr/local/gr/lib/libGR.so (compatibility version 0.0.0, current version 0.0.0)
        /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
        /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 17.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

In my environment, creating a symbolic link to ~/.julia/v0.4/GR/deps/gr in /usr/local solved this problem.


~/.j/v/G/examples ((v0.9.14)|✔) $ git show -s
commit bef725ca75d87a331fdc68c84f4e36dbde02b09b
Author: Josef Heinen <[email protected]>
Date:   Thu Oct 22 08:24:12 2015 +0200

    Support architecture specific tar balls
julia> versioninfo()
Julia Version 0.4.2
Commit bb73f34* (2015-12-06 21:47 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i5-4288U CPU @ 2.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

Problem showing a png() using Plots.plot(img)

Hi,

Not sure if this should go to GR.jl or Plots.jl... (CC @tbreloff)

But when I try to load a simple image using v0.5 Julia and latest release of packages, the plot is okay in pyplot, but not gr:

using Plots, Images
f = expanduser("~/.julia/v0.5/Images/docs/src/img/rose_hsv.png")
img = Images.load(f)
pyplot()
plot(img)

gr()
plot(img)

Results in the following two windows:

ohoh

Minimum OSX version == 10.9 ?

As you might guess I am on 10.8 and got the following after the install went through without hiccup

julia> using GR

julia> GR.plot(rand(10))
dyld: lazy symbol binding failed: Symbol not found: ___sincos_stret
  Referenced from: ~/.julia/v0.4/GR/deps/gr/lib/libGR.so
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: ___sincos_stret
  Referenced from: ~/.julia/v0.4/GR/deps/gr/lib/libGR.so
  Expected in: /usr/lib/libSystem.B.dylib

Apparently sincos et al were introduced in 10.9 ...

Any chance the pre-compiled GR framework could support 10.8?

Set size of saved png

Hi,
Is there a way to set the size/dpi of a png produced using beginprint?

Also many thanks for the package! I really like the performance and clean API.

How to set aspect ratio?

Hi, how do I set the aspect ratio of a plot?

In Plots.jl, this works for pyplot() but not for gr()

w = rand(10,2)
pyplot()
plot(w[:,1], w[:,2], w=9, aspect_ratio=1)
gr()
plot(w[:,1], w[:,2], w=9, aspect_ratio=1)

Packaging on Archlinux, problem with Julia and inline("mov")

Hi! I am trying to packaging GR on Archlinux (you can find the package here). I can successfully import GR in Julia and Python, however in Julia the following code

using GR
inline("mov")
x = collect(0:0.01:2*pi)
for i = 1:200
  plot(x,sin(x + i/10)
end

prompts the following error

GKS: /usr/lib/./movplugin.so: undefined symbol: gks_movplugin

Pkg.test("GR") fails on 32-bit platform (64-bit libs auto-installed)

Using Pkg.add("GR") on a 32-bit platform downloads an unusable 64-bit library.

$ ./julia -E 'Pkg.add("GR")'
INFO: Cloning cache of GR from git://github.com/jheinen/GR.jl.git
INFO: Installing GR v0.9.4
INFO: Building GR
INFO: Downloading pre-compiled GR 0.13.1 binary
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 29.9M  100 29.9M    0     0  1726k      0  0:00:17  0:00:17 --:--:-- 2067k
INFO: Package database updated
nothing
$ ./julia -E 'Pkg.test("GR")'
INFO: Testing GR
dlerror loading '/home/rick/.julia/v0.4/GR/deps/gr/lib/libGR.so': /home/rick/.julia/v0.4/GR/deps/gr/lib/libGR.so: wrong ELF class: ELFCLASS64
ERROR: LoadError: test error in expression: tick(1.2,3.14) == 0.5
error compiling tick: could not load library /home/rick/.julia/v0.4/GR/deps/gr/lib/libGR.so
 in anonymous at test.jl:89
 in do_test at test.jl:49
 in include at ./boot.jl:253
 in include_from_node1 at loading.jl:133
 in process_options at ./client.jl:312
 in _start at ./client.jl:412
while loading /home/rick/.julia/v0.4/GR/test/runtests.jl, in expression starting on line 4

=================================[ ERROR: GR ]==================================

failed process: Process(`/usr/local/src/julia/julia/usr/bin/julia --check-bounds=yes --code-coverage=none --color=no /home/rick/.julia/v0.4/GR/test/runtests.jl`, ProcessExited(1)) [1]

================================================================================
INFO: No packages to install, update or remove
ERROR: GR had test errors
 in error at error.jl:21
 in test at pkg/entry.jl:746
 in anonymous at pkg/dir.jl:31
 in cd at file.jl:22
 in cd at pkg/dir.jl:31
 in test at pkg.jl:71
 in process_options at ./client.jl:294
 in _start at ./client.jl:412

$ ./julia -e 'versioninfo()'
Julia Version 0.4.0-dev+5199
Commit 5ea501d (2015-06-04 05:45 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 Banias)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

SVG --> CGM.

I noticed GR supports SVG output - but I cannot tell if it can read in SVG drawings and render it on the GR backend.

I ask because GR seems to have all the parts necessary to convert SVG files to CGM (It might even be an ideal backend for a "vector" image converter).

Though SVG is supposed to be widely supported, CGM is actually better supported in many cases (even within MS applications).

Saving outputs as png

I'd love to use GR as an alternative to (slow) matplotlib.
However, I often want to save outputs as png,
which currently does not seem to be possible.
I don't know what gr3.save is supposed to do
but the following code produces a black output.

using GR
GR.inline()
GR.cellarray(0,1,0,1,50,50,round(255*rand(50,50)))
GR.show()
GR.gr3.save("foo.png", 300, 300)

Am I using it the wrong way?

Incorrect window size.

Hi Josef,
Thanks again for you library..

Аfter several unsuccessful attempts to figure out what is wrong with window size i'm writing this issue. I tried the code, you gave me to setup window size in pixels:

w = 400
h = 300
mwidth, mheight, width, height = GR.inqdspsize()
if w >= h
    ratio = float(h) / w
    msize = mwidth * w / width
    GR.setwsviewport(0, msize, 0, msize * ratio)
    GR.setwswindow(0, 1, 0, ratio)
else
    ratio = float(w) / h
    msize = mheight * h / height
    GR.setwsviewport(0, msize * ratio, 0, msize)
    GR.setwswindow(0, ratio, 0, 1)
end

setviewport(0, 1, 0, ratio)
setwindow(1, w, 1, h)
#...
drawrect(1, w, 1, h)
#...

But, the size of the window is not 400x300. It's about 485x410. See this screenshot for details.

What i'm doing wrong?

Grid drawn for imshow

I recently updated to the latest master branch and noticed that imshow now draws a grid background for the plot:

imshow(randn((12,10)))

unknown

In a build a few weeks ago, the background was not there.

Thanks in advance for the help!

Size of a plot

Is it posible to change the size of a plot when exporting to a file?
I tried

GR.beginprint("plot.pdf")
GR.plot(x, y, width=100, height=100)
GR.endprint()

But it didn't work.
Thanks

Generating videos from the REPL

In order to generate videos (from the REPL) I find myself issuing code such as the following:

GR.inline("mov")
for i in 1:n
   plot(...)
end
GR.show();     # Writes the file to disk

Is there an easier/better way to do this?

If not, then

  • after doing this, how do I reset rendering back to the (OS X) GKS terminal (if I manually call GR.inline(400) then the above loop would then opens a new window for each plot, rather than the default behaviour)
  • is it possible to introduce a macro (e.g., @mov "filename.mov" for i in 1:n) which could generate the video then revert rendering to the GKS terminal?

I have attempted to use Plots.jl's animation feature to achieve the same functionality, but I find that the rendered output is distorted (at least when drawing heatmaps).

Greek letters

The docs indicate that syntax like \alpha should render a Greek symbol (without requiring LaTeX). But I see the following:

import GR
GR.plot(collect(1:10), collect(1:10))
GR.textext(0.2, 0.8, "\\alpha, \\beta, \\gamma")

example

Is this a font issue?

julia> versioninfo()
Julia Version 0.4.0
Commit 0ff703b* (2015-10-08 06:20 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin13.4.0)
  CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

XIO: fatal IO error 11

julia> include("/tmp/anim.jl")
INFO: Loading help data...
fps (mpl): 19.0
fps  (GR): 115.0
  speedup:    6.1

julia> XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
      after 48081 requests (47844 known processed) with 0 events remaining.
X Protocol error detected by server: BadWindow (invalid Window parameter)
Failed request major op code 15 (X_QueryTree)
Invoked from within GKS function id 3

Stem plots

Is there currently a way to do stem plots with GR. This might be more a feature request.

MATLAB
stem(x, 'filled')
image

Thanks for the work you put into GR.

LaTeX support

The key thing that's stopping me using GR is that I can't pass a LaTeX string (e.g. from the LaTeXStrings.jl package) and have it rendered as an axis label or whatever. I know there's some support for Greek letters but it's not as complete as matplotlib, which will accept basically any LaTeX you give it.

Is this something that GR will be able to do one day?

Oh man... Windows install nightmare

julia> Pkg.add("GR")
WARNING: julia is fixed at 0.4.2 conflicting with requirement for Unitful: [0.5.0-,∞)
INFO: Cloning cache of GR from git://github.com/jheinen/GR.jl.git
INFO: Installing GR v0.9.17
INFO: Removing ColorVectorSpace v0.1.1
INFO: Removing ImageMagick v0.1.3
INFO: Removing Images v0.5.3
INFO: Removing SIUnits v0.0.6
INFO: Removing TexExtensions v0.0.3
INFO: Building GR
INFO: Downloading pre-compiled GR 0.17.3 binary
=================================[ ERROR: GR ]==================================

LoadError: chmod: no such file or directory (ENOENT)
while loading C:\Users\Eric Forgy\.julia\v0.4\GR\deps\build.jl, in expression starting on line 25

================================================================================

================================[ BUILD ERRORS ]=================================

WARNING: GR had build errors.

 - packages with build errors remain installed in C:\Users\Eric Forgy\.julia\v0.4
 - build the package(s) and all dependencies with `Pkg.build("GR")`
 - build a single package by running its `deps/build.jl` script

=================================================================================
INFO: Package database updated
julia>

Why did installing this package remove my other unrelated packages?

julia> versioninfo()
Julia Version 0.4.2
Commit bb73f34 (2015-12-06 21:47 UTC)
Platform Info:
  System: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

[Windows x64] Fails to export images

On Windows, when trying to export simple plots, I get the following error message:

---------------------------
GKS
---------------------------
gsplugin.dll: can't load library
---------------------------
OK   
---------------------------

I use the following script to trigger the error:

using GR
GR.plot([1,2],[1,2])
GR.savefig("F:/a.png")

With a Plots.jl script, the same error appears:

using Plots
Plots.gr()
Plots.plot([1,2],[1,2])
Plots.savefig("F:/a.png")

However, both perfectly show a window with the plot in it.

I guess something went wrong with the installation of GR. I use version 0.13.0, installed directly with Pkg.install("GR"); Julia is 0.4.6, x64, on Windows 10 x64. I have a file C:\Users\Thibaut\.julia\v0.4\GR\deps\gr\gsplugin.dll, so it seems it is not missing.

Looking with Dependency Walker (http://www.dependencywalker.com/) at that file, it looks like it's missing a file: gsdll64.dll. It looks like Ghostscript, so I downloaded it (http://ghostscript.com/download/gsdnld.html) and put the corresponding DLL in the same folder. For Dependency Walker, everything looks OK… but I still get the same error!

capture

Is there any missing dependency hidden somewhere? Or a bug of another kind?

Plot not displayed with 1 million points

The snippet of code below with Plots.jl does not display a plot in Jupyter notebooks:

using Plots
gr()

N = 1000000

x = randn(N)
y = randn(N)
z = randn(N)
scatter(x, y, z, markersize=.1, legend=false)

If I reduce the number of points, the plot is displayed.

inline("mov") on windows failiure

I am not sure if I require other installation steps I may have missed but just adding the package and trying out the examples using inline("mov") do not work on Windows 10 x64 inside a jupyter notebook.

Feature request : Zoom, pan

GR is a great package, especially with respect to plotting speed. In the past I have used Gadly with the GTKInteract package, which allows me to zoom/pan around my plots. I'm sure these features are on the road map for GR as well, so this is just me registering my interest in those features. Keep up the good work!

Problem with setting line attributes on Windows

For some reason the following doesn't set the line attributes for me on Windows 7 (GR 0.18) in GKS 5 window . (I just get a thin black line).

GR.setlinetype(1)
GR.setlinecolorind(10)
GR.setlinewidth(3)

It works if output SVG and also for the on screen device on Ubuntu 16.04. For linetype 2 output on sceen works also on Windows:

GR.setlinetype(2)
GR.setlinecolorind(10)
GR.setlinewidth(3)

This produces thicker dotted blue line.

savefig error for png

saving to png format produces the following error msg:

GKS: /home/abieler/.julia/v0.5/GR/deps/gr/lib/cairoplugin.so: undefined symbol: XRenderCompositeText32

On 64 bit Linux Mint 17.2 Rafaela (Ubuntu Trusty)

Window breaks down in fullscreen mode

This is simple bug. When i click on fullscreen button at the right top corner the window breaks down. See screenshot for details. Normal window - on the left, in fullscreen mode - on the right.

P.S. I use windows 8.1.

surface() crashes on Windows when rotation == 0

I'm experiencing some crashes when plotting 2-dimensional histograms in Plots.jl when using the GR framework with a large amount of data on Windows 10.

The following code reproduces the issue in GR using a setup that is similar to the one called in Plots.jl for 2-dimensional histograms:

using GR

setwindow(0, 1000, 0, 1000)
setviewport(0, 1, 0, 1)

x = collect(1:1000)
y = collect(1:1000)
z = [rand() for x in x, y in y]

setspace(0, 1, 0, 90)

surface(x, y, z, GR.OPTION_HEATMAP)

The critical piece of code is the 0 that specifies the rotation in setspace(Int64, Int64, 0, Int64). The issue only occurs for reasonably large amounts of data.

Can't fit world coordinates to the active workstation

Hi, again :)

This second issue is a part of more global problem: drawing a pixel in a window with special width and height. As i told before, i use this code for setting window size:

mwidth, mheight, width, height = GR.inqdspsize()
w = 400
h = 300
if w >= h
    ratio = float(h) / w
    msize = mwidth * w / width
    GR.setwsviewport(0, msize, 0, msize * ratio)
    GR.setwswindow(0, 1, 0, ratio)
else
    ratio = float(w) / h
    msize = mheight * h / height
    GR.setwsviewport(0, msize * ratio, 0, msize)
    GR.setwswindow(0, ratio, 0, 1)
end

But i can't set world coordinates to the same size, like window has. Let's say, i need a window 400x300px. And if i call for example, fillrect(1, 400, 1, 300) it will not has maximum size. I found, that on my resolution i have to add 7.5 to x and -10 to y to fix the problem. But why?

See full code version here:

mwidth, mheight, width, height = GR.inqdspsize()
w = 400
h = 300
if w >= h
    ratio = float(h) / w
    msize = mwidth * w / width
    GR.setwsviewport(0, msize, 0, msize * ratio)
    GR.setwswindow(0, 1, 0, ratio)
else
    ratio = float(w) / h
    msize = mheight * h / height
    GR.setwsviewport(0, msize * ratio, 0, msize)
    GR.setwswindow(0, ratio, 0, 1)
end

setviewport(0, 1, 0, ratio)
#setwindow(1, w + 7.5, -10, h) # this line fixes size problem on 1280x720 resolution
setwindow(1, w, 1, h)
#...
drawrect(1, w, 1, h) # draws incorrect rect

See this screenshot for details. May be i doing something wrong?

Feature request: simple Matlab/Octave-like functions

Hi Josef,

Perhaps it is too much to ask, but I was wondering if it is possible for you to add a few Matlab-like functions to GR, something that can be called for daily quick visualization of 2D and 3D data. Or alternatively provide a few minimum working example in the form of a notebook.
There are a few that comes to my mind that I use most of the time in Matlab/octave/matplotlib without touching the default output (here are some of the octave code that I have written in Octave/Matlab for visualization of data on different coordinates)
plot(x,y): is already there.
xlabel(string): label for the x axis
ylabel(string): label for the y axis
surf(x,y,z): 3D plot similar to surface with a default view and axis, where x and y are vectors and z is a 2D array
pcolor(x,y,z): 2D visualization of 3D data with a default colormap
contour(x,y,z) and contourf(x,y,z)
slice: would be fantastic!
List of octave 3D visualization functions

Thanks a lot in advance.

Closing figure and figure window is gone forever

When i close a figure window, and then attempt to plot again, then the figure window is gone forever. I'd like it to pop up again by itself. (as matlab would do)

Here's what i do:

  1. copy/paste the mandel.jl source to the REPL.
  2. close the figure window.
  3. execute the final mandel for-loop one more time.

Problem: it does not show me the figure in step 3.

Install error on linux

When installing GR with Pkg.add("GR") I get the follwing run time error

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.6 (2016-06-19 17:16 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-unknown-linux-gnu

julia> using GR

julia> GR.plot(1:10,randn(10))
ERROR: error compiling plot_data: error compiling __plot_data#1__: error compiling clearws: could not load library "/home/jpf/.julia/v0.4/GR/deps/gr/lib/libGR.so"
libXt.so.6: cannot open shared object file: No such file or directory
 in plot at /home/jpf/.julia/v0.4/GR/src/jlgr.jl:826
 in plot at /home/jpf/.julia/v0.4/GR/src/GR.jl:1220

The build appeared successful

julia> Pkg.add("GR")
INFO: Cloning cache of GR from git://github.com/jheinen/GR.jl.git
INFO: Installing GR v0.13.0
INFO: Building GR
INFO: Downloading pre-compiled GR 0.18.0 binary
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 39.1M  100 39.1M    0     0  7391k      0  0:00:05  0:00:05 --:--:-- 9168k

On a RHEL machine.
This also happened on an Ubuntu 16.04 machine.

GR + Atom @Mac

Hi Josef,

I'm using Atom, GR directly (using GR), in a mac computer.
As I was facing the issue, already reported, where GKS has to be opened, I'm trying to get plots into the plots pane of Atom.

Issues:

in the following example:

x = linspace(0,10,150)
y = cos(5*x)

title("2-D Line Plot")
xlabel("x")
ylabel("cos(5x)")
plot(x,y,"b")

title, xlabel, ylabel are not printed if I write like this, if I execute them after the plot command, the commands title, xlabel, and ylabel overwrite the previous one. I've tried hold(true), but then I get a blank image.

GR.beginprint("$dataPath$pltfile")
plot(something)
GR.endgraphics()

GR.beginprint("$dataPath$pltfile2")
plot(something else)
GR.endgraphics()

I don't get to save the second plot into the pltfile2 file.

GR.setmarkertype(4)
doesn't work for me either

thanks,
Let me know if you have any examples on how to have inline plots in atom.

thanks a lot

Segfault in 0.3.8

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.3.8 (2015-04-30 23:40 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org release
|__/                   |  x86_64-linux-gnu

julia> Pkg.add("GR")
INFO: Cloning cache of GR from git://github.com/jheinen/GR.jl.git
INFO: Installing GR v0.9.3
INFO: Building GR
INFO: Downloading pre-compiled GR 0.13.0 binary
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 31.1M  100 31.1M    0     0  1303k      0  0:00:24  0:00:24 --:--:--  857k
INFO: Package database updated
INFO: METADATA is out-of-date — you may not have the latest version of GR
INFO: Use `Pkg.update()` to get the latest versions of your packages

julia> using GR

signal (11): Segmentation fault
unknown function (ip: -914805894)
unknown function (ip: -914805789)
jl_get_binding at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
jl_get_global at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
jl_module_run_initializer at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
unknown function (ip: -914916237)
unknown function (ip: -914917387)
unknown function (ip: -914915635)
jl_load at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
include at ./boot.jl:245
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
include_from_node1 at ./loading.jl:128
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
unknown function (ip: -914981944)
unknown function (ip: -914985776)
unknown function (ip: -914918342)
jl_f_top_eval at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
reload_path at loading.jl:152
_require at loading.jl:67
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
require at loading.jl:51
jlcall_require_20631 at  (unknown line)
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
unknown function (ip: -914922547)
unknown function (ip: -914917709)
jl_f_top_eval at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
eval_user_input at REPL.jl:53
jlcall_eval_user_input_19906 at  (unknown line)
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
anonymous at task.jl:95
jl_handle_stack_switch at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
julia_trampoline at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
unknown function (ip: 4199613)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 4199667)
unknown function (ip: 0)

conversion to latin1

Hi!!!
Conversion to latin1 fails for multibyte characters:

using Plots
gr()
scatter([0], [0], series_annotations = ["\u2200 or B"],
             xlims = (-.1, .1), ylims = (-.1,.1))

throws BoundsError: attempt to access 6-element Array{UInt8,1} at index [7]

I think it would be better to print garbled text in this case than throw an error, so I fixed it locally by changing

function latin1(string)
  b = convert(Array{UInt8}, string)
  s = zeros(UInt8, length(string))
...

to

function latin1(string)
  b = convert(Array{UInt8}, string)
  s = zeros(UInt8, length(b))
...

in GR.jl

Let me know if that's ok and I'll PR it!

Thanks!

Using gr

Hi Josef,

Thanks for GR (+other developers). It looks very promising. It seems faster than other alternatives out there.

Problem:
Documentation seems limited, and so are examples.

Question 1:
GR appears to be usable as an alternative for the functionality that Cairo provides. Am I understanding this correctly?

Question 2:
How would I render a plot on Gtk backend instead of the standard GKS pop-up window?

It looks like you can use openws() for workstation_type = 371, but I am unsure what the other parameters are for. I also am not clear on how to use this particular API (none of the drawing functions appear to take workstation_id as an argument).

Question 3:
Can you have a "workstation" that writes to an uncompressed (RAW) bitmap (as opposed to PNG, for example)?

Once open, can this bitmap be rendered on another canvas (ex: the Cairo backend of a Gtk window?)

Thanks,

MA

quartzplugin.so not found

When I use GR (with Julia 0.4) I get:

GKS: dlopen(/usr/local/gr/lib/quartzplugin.so, 1): image not found

Things (e.g., writing to a PDF file) still work, though.

Backtrace for newtons_crade.jl

Hi,
I get the following backtrace running newtons_cradle (a window appears with a horizontal box and a vertical line). This is with julia HEAD and presumably the latest version of GR.

I've got this on both my mac and linux. Let me know if I can help further. (I have edited the warnings about int(x))

julia> include("newtons_cradle.jl")
WARNING: int(x) is deprecated, use Int(x) instead.
 in depwarn at ./deprecated.jl:73
...
while loading /mhome/damtp/cbi/sje30/.julia/v0.4/GR/examples/newtons_cradle.jl, in expression starting on line 46
WARNING: int(x) is deprecated, use Int(x) instead.
 in depwarn at ./deprecated.jl:73
 while loading /mhome/damtp/cbi/sje30/.julia/v0.4/GR/examples/newtons_cradle.jl, in expression starting on line 46
ERROR: LoadError: InexactError()
 in copy! at abstractarray.jl:307
 in drawimage at /home/sje30/.julia/v0.4/GR/src/GR.jl:809
 in draw_cradle at /mhome/damtp/cbi/sje30/.julia/v0.4/GR/examples/newtons_cradle.jl:33
 [inlined code] from /mhome/damtp/cbi/sje30/.julia/v0.4/GR/examples/newtons_cradle.jl:55
 in anonymous at no file:0
 in include at ./boot.jl:260
 in include_from_node1 at ./loading.jl:271
 in eval_user_input at REPL.jl:64
 [inlined code] from REPL.jl:93
 in anonymous at task.jl:68
while loading /mhome/damtp/cbi/sje30/.julia/v0.4/GR/examples/newtons_cradle.jl, in expression starting on line 50

Feature requests: subplots, legend, hold

Hi,

I have been using your module recently and it is formidable.
I have some feature requests I hope you can easily add.

  1. My first one would be to have hold function (as in Matlab).
  2. Also, I would like to be able to use subplots like in pylab/matlab.
  3. A savefig function would be very usefull (this is quite simple to do actually)
  4. Finally, I can't find a legend function for GR.plot

These features would simplify the production of publishable figures,

Thank you for your help and your hard work,

Best regards,

Rom1

Pkg.add("GR") Can't install on 32-bit Windows platform

julia> Pkg.add("GR")
INFO: Installing GR v0.9.14
JULIA_PKGDIR=O:\Julia-0.4.1\bin..\share\julia\site
INFO: Building GR
INFO: Downloading pre-compiled GR 0.17.1 binary
=================================[ ERROR: GR ]==================================

LoadError: automatic download failed (error: 2148270086): http://gr-framework.or
g/downloads/gr-0.17.1-Windows-i686.tar.gz
while loading O:\Julia-0.4.1\share\julia\site\v0.4\GR\deps\build.jl, in expressi
on starting on line 11

================================[ BUILD ERRORS ]================================

WARNING: GR had build errors.

  • packages with build errors remain installed in O:\Julia-0.4.1\share\julia\sit
    e\v0.4
  • build the package(s) and all dependencies with Pkg.build("GR")
  • build a single package by running its deps/build.jl script

INFO: Package database updated
INFO: METADATA is out-of-date —— you may not have the latest version of GR
INFO: Use Pkg.update() to get the latest versions of your packages

add detail to project description

Thanks for creating GR.jl.
At the moment, the package listing for GR (http://pkg.julialang.org/) doesn't provide much of a clue as to what GR is about: "No description available."

I believe it will pick up your project description when the listing is next updated, but that still won't provide any clues as to what GR is about: "The GR module for Julia:

How about a project description along the lines of: "Julia package for GR, a visualization framework"

Locating libGR.so

Due to certain restrictions, I've installed the GR framework using the binary package for the Anaconda python distribution (using "conda install -c https://conda.binstar.org/jheinen gr") rather than compiling from source and I've verified that it works from the python interpreter (which is in my global $PATH).

Unfortunately, when I try to use "polyline(rand(100), rand(100))" from Julia, I get the error "ERROR: error compiling polyline: could not load module /usr/local/gr/lib/libGR.so: /usr/local/gr/lib/libGR.so: cannot open shared object file: No such file or directory". I skimmed through the source of GR.jl and tried copying libGR.so to $HOME/gr/lib, since it seemed to check that path for the shared library, but this did not change the error. Perhaps I'm missing something obvious here, but it may be the case that handling of the library dependency in GR.jl could be improved.

Either way, looking forward to using this great framework from my Julia code!

Launching GKSTerm failed.

On my mac, I now can't seem to get GR started:

julia> versioninfo()
Julia Version 0.5.0
Commit 3c9d753 (2016-09-19 18:14 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin13.4.0)
  CPU: Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, has well)


julia> using GR
INFO: Recompiling stale cache file /Users/stephen/.julia/lib/v0.5/GR.ji for module GR.

julia> GR.plot(rand(10))
2016-10-29 17:12:48.727 julia[9174:376773] Launching GKSTerm failed.

This is with the latest version of GR installed after first deleting ~/.julia/v0.5

any clues?

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.