Skip to content

Instantly share code, notes, and snippets.

@vsivsi
Created February 24, 2020 18:32
Show Gist options
  • Save vsivsi/30f8bd862c1faef7a7710764b98d80b0 to your computer and use it in GitHub Desktop.
Save vsivsi/30f8bd862c1faef7a7710764b98d80b0 to your computer and use it in GitHub Desktop.
Repro of gophernotes + gonum/plot issue
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"ename": "ERROR",
"evalue": "repl.go:26:7: cannot use <*gonum.org/v1/plot/plotter.BarChart> as <gonum.org/v1/plot.Plotter> in argument to p.Add",
"output_type": "error",
"traceback": [
"repl.go:26:7: cannot use <*gonum.org/v1/plot/plotter.BarChart> as <gonum.org/v1/plot.Plotter> in argument to p.Add"
]
}
],
"source": [
"import (\n",
" \"gonum.org/v1/plot\"\n",
" \"gonum.org/v1/plot/plotter\"\n",
" \"gonum.org/v1/plot/vg\"\n",
" \"image/color\"\n",
" \"log\"\n",
")\n",
"groupA := plotter.Values{20, 35, 30, 35, 27}\n",
"\n",
"p, err := plot.New()\n",
"if err != nil {\n",
" log.Panic(err)\n",
"}\n",
"p.Title.Text = \"Bar chart\"\n",
"p.Y.Label.Text = \"Heights\"\n",
"\n",
"w := vg.Points(8)\n",
"\n",
"barsA, err := plotter.NewBarChart(groupA, w)\n",
"if err != nil {\n",
" log.Panic(err)\n",
"}\n",
"barsA.Color = color.RGBA{R: 255, A: 255}\n",
"barsA.Offset = -w / 2\n",
"\n",
"p.Add(barsA)\n",
"p.Legend.Add(\"A\", barsA)\n",
"err = p.Save(300, 250, \"barChart.png\")\n",
"if err != nil {\n",
" log.Panic(err)\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Go",
"language": "go",
"name": "gophernotes"
},
"language_info": {
"codemirror_mode": "",
"file_extension": ".go",
"mimetype": "",
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.13.8"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment