Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blank window has opened when execute sample code. #56

Open
teslur opened this issue Jan 25, 2020 · 1 comment
Open

Blank window has opened when execute sample code. #56

teslur opened this issue Jan 25, 2020 · 1 comment
Labels
wontfix This will not be worked on

Comments

@teslur
Copy link

teslur commented Jan 25, 2020

When I execute sample code that is written in Usage section of README.md, blank window has opened.

Environment

$ uname -a
Darwin xxxxMacBook-Pro.local 18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64

$ ruby --version
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin18]

Gemfile, Gemfile.lock and executed sample code

$ cat Gemfile
source "https://rubygems.org"

gem 'charty'
gem 'numo-narray'
gem 'matplotlib'

$ cat Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    charty (0.2.1)
      red-colors
    matplotlib (1.1.0)
      pycall (>= 1.0.0)
    numo-narray (0.9.1.6)
    pycall (1.3.0)
    red-colors (0.1.1)

PLATFORMS
  ruby

DEPENDENCIES
  charty
  matplotlib
  numo-narray

BUNDLED WITH
   1.17.2

$ cat sample_1.rb
require 'bundler/setup'
require 'charty'

charty = Charty::Plotter.new(:pyplot)

bar = charty.bar do
  series [0,1,2,3,4], [10,40,20,90,70], label: "sample1"
  series [0,1,2,3,4], [90,80,70,60,50], label: "sample2"
  series [0,1,2,3,4,5,6,7,8], [50,60,20,30,10, 90, 0, 100, 50], label: "sample3"
  range x: 0..10, y: 1..100
  xlabel 'foo'
  ylabel 'bar'
  title 'bar plot'
end
bar.render("sample_images/bar_pyplot.png")

Result

  • Blank window has opened.

スクリーンショット 2020-01-25 14 06 14

  • Following image has been saved as sample_images/bar_pyplot.png.
    bar_pyplot

When I execute same code and Gemefile in following environment, the window shows graphs.

$ uname -a
Darwin xxxxMacBook-Pro.local 18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64

$ ruby --version
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]

スクリーンショット 2020-01-25 22 38 14

@mrkn
Copy link
Member

mrkn commented May 4, 2021

@teslur Sorry for the response to be late.
Avoiding to open a blank window, you may need to explicitly specify agg backend in matplotlib.

I think inserting the following code before or after charty = Charty::Plotter.new(:pyplot) resolves this issue.

require "matplotlib"
Matplotlib.use(:agg)

@mrkn mrkn added the wontfix This will not be worked on label May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants