plot/vg: Unable to add or visualize an Arc from vg.Path
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- go
- Ambito
- data-visualization
Direzione di ricerca
Inizia con l’esempio minimo ed esamina vg.Path.Arc insieme alla chiamata canvas Stroke; l’issue fornisce la riproduzione esatta e la geometria prevista. Verifica il fix generando la PNG e confermando che il semicerchio superiore appaia accanto agli assi e al titolo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
What version of Go and Gonum/plot are you using?
go 1.20
gonum.org/v1/plot v0.13.0
- Lingua principale
- Go
- Stelle
- 3k
- Fork
- 202
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di gonum/plot
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 52/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 32/100
-
plot/plotter: NewHist(binPoints) panic when a small negative number is usedForse già presa @SashaMIT l’ha presa 17 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
containerd/containerd#14485 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
SocialGouv/iterion#2800 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] A NaN or infinite latency in a batch response breaks the adaptive concurrency controllerApertaarea/batch area/orchestration kind/misc
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vllm-project/aibrix#3339 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
Kong/kong-operator#6340 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100