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

Showing a figure with a Graphics entry with a relative path fails #283

Open
KristofferC opened this issue Sep 20, 2021 · 1 comment · May be fixed by #295
Open

Showing a figure with a Graphics entry with a relative path fails #283

KristofferC opened this issue Sep 20, 2021 · 1 comment · May be fixed by #295

Comments

@KristofferC
Copy link
Owner

Reported from slack

using PGFPlotsX
using KernelDensity
using ColorSchemes

data = (rand(1000), rand(1000))

k = kde(data)

npoints = 400
es = map(extrema, data)
rgs = map(e -> range(e...; length=npoints), es)
res = pdf(k, rgs...)

res = reverse(transpose(res), dims = 1)

cs = get(ColorSchemes.jet1, res, (minimum(res), maximum(res)))

PNGFiles.save("img.png", cs)

figure = Axis(
	PGFPlotsX.Options(
		:enlargelimits => "false",
		:axis_on_top => nothing,
	),
	Plot(
		PGFPlotsX.Graphics(
			PGFPlotsX.Options(
				:xmin => first(k.x),
				:xmax => last(k.x),
				:ymin => first(k.y),
				:ymax => last(k.y),
			),
			"img.png"
		)
	)
)

fails to show the figure because I guess we put the .tex file in a temp folder. I think we need to put it in the same folder.

@rs7q5
Copy link

rs7q5 commented Nov 3, 2021

Ran into this issue today as well. You can solve it by defining graphicspath or by providing it the absolute path. But if on Windows, you have to use raw"{filename} because of the \\ present in a folder name. Would be great if one could provide the folder separately and then the filename. I haven't figured out a way to get the string literal to accept a variable folder name using $ like normal.

@tpapp tpapp linked a pull request May 2, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants