Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

plot/vg: Unable to add or visualize an Arc from vg.Path

オープン
#778 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
go

調査の方向性

最小限の例から始め、canvas Stroke の呼び出しと併せて vg.Path.Arc を調べます。issue には正確な再現手順と期待されるジオメトリが記載されています。PNG を生成し、上半円が軸とタイトルの横に表示されることを確認して fix を検証します。

索引モデルが issue の本文から書いたものです。

説明

What are you trying to do?

I am trying to draw arcs on a plot and here as an example I specifically try to display an arc with center (0,0) and radius of 1 from the angle 0 to pi and save that to a .png file.

What did you do?

Here is a minimal working example of the code I used:


package main

import (
	"math"

	"gonum.org/v1/plot"
	"gonum.org/v1/plot/vg"
	"gonum.org/v1/plot/vg/draw"
	"gonum.org/v1/plot/vg/vgimg"
)

func main() {
	p := plot.New()
	p.Title.Text = "Arc Plot Example"
	p.X.Label.Text = "X"
	p.Y.Label.Text = "Y"

        // Create Canvas
	cnvs := vgimg.PngCanvas{
		Canvas: vgimg.New(5*vg.Centimeter, 5*vg.Centimeter),
	}

	// Draw arc
	centerX := 0.0      // X-coordinate of the center of the circle
	centerY := 0.0      // Y-coordinate of the center of the circle
	radius := 1.0       // Radius of the circle
	startAngle := 0.0   // Start angle of the arc (in radians)
	endAngle := math.Pi // End angle of the arc (in radians)

	path := vg.Path{}
	path.Arc(vg.Point{X: vg.Length(centerX), Y: vg.Length(centerY)}, vg.Length(radius), startAngle, endAngle) // Add the arc to the path
	cnvs.Stroke(path)

        // Add the canvas and the Arc to the plot
	p.Draw(draw.New(cnvs))

	// Save plot and also try to save canvas to file directly
	
	// Save the plot to a PNG file.
	if err := p.Save(5*vg.Centimeter, 5*vg.Centimeter, "figures/arc1.png"); err != nil {
		panic(err)
	}

	// Save the canvas directly to a PNG file.
	w, err := os.Create("figures/arc2.png")
	if err != nil {
		panic(err)
	}
	defer w.Close()
	if _, err := cnvs.WriteTo(w); err != nil {
		panic(err)
	}

	// pic.ShowImage(cnvs.Image())
}

I tried to use the go playground and pic.ShowImage(img) as suggested but it won't compile. Still, find the link below if it can work for you...
https://go.dev/play/p/KMPRsOUcO-0

What did you expect to happen?

It should draw the arc (line) as described above, i.e. we should see half a circle spanning from -1 to 1 with a radius of 1 on the side of the positive y-axis values.

What actually happened?

Nothing is drawn to the image except the axes and title.

arc1

What version of Go and Gonum/plot are you using?

go 1.20
gonum.org/v1/plot v0.13.0

主要言語
Go
スター
3k
フォーク
202
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

gonum/plot のほかの issue

gonum/plot の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。