-
Notifications
You must be signed in to change notification settings - Fork 40
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
Support plotting surface data #11
Comments
Good suggestion. Could you for reference link to an example or a stackoverflow post with some code so I can see how the tex should look. |
The answers to this question show the format, and a use both with "matrix plot" and "surf". Basically you need to give x y z points. I am personally trying to do a matrix plot (page 171 of the manual), but I find that doing Plot(data,
{
"matrix plot"
}) does not work. The code for the data coordinates looks like this, which is what the Coordinates method could do automatically given xx = repmat(x,length(y))
yy = vec(repmat(y.',length(x))
zz = vec(z)
data = Coordinates(xx,yy,zz) |
Are the empty lines needed for the output to be correct or are they just for clarity in the examples? |
I think there needs to be one, although the number of rows or columns can be specified in which case it's not necessary:
|
I think my case will be easier with a table. Will make an example as soon as I figure it out. |
I have encountered the same problem.
which does not compile. After you add the blank lines
it works. I apologize for broken formatting, just do not know, how to do it properly. |
Supporting the table format would also allow contour plots. See the |
Using Contour.jl already works (see last example in https://github.com/KristofferC/PGFPlotsXExamples/blob/master/examples/custom_types.ipynb). |
@jebej: this reproduces the first example on p 171: x = repeat(0:2, outer = 3)
y = repeat(0:2, inner = 3)
meta = ["color=$c" for c in ["red", "blue", "yellow", "black", "brown", "magenta", "green", "red", "white"]]
c = Coordinates(Float64.(hcat(x, y))'; metadata = meta)
p = @pgf Axis(Plot(c,
{
matrix_plot,
mark = "*",
nodes_near_coords = raw"\coordindex",
"mesh/color input" = "explicit",
"mesh/cols" = 3,
}), { enlargelimits = false }) Will make a PR to the examples repo soon. |
This is a step towards fixing #44, and is in accordance with the principles laid out there, but not the exact syntax proposed there since it was found to be impractical. Also fixes #11. 1. Introduce the `Coordinate` type for individual coordinates. Validate arguments and fail early. 2. Introduce `EmptyLine` for jumps/scanlines. This addresses #11. 3. Rewrite `Coordinates` to contain the above. (`<: OptionType` was removed, because it has no options). 4. Convenience constructors for creating coordinates from vectors, matrices, iterable objects, with or without error bars. Docstrings for the API. 5. Add examples of all the new syntax to the gallery (some of this should be moved to the documentation eventually, that will come later after other changes). 6. 2D histograms now work (example will be added later, when `Table` are redesigned similarly).
* Rework coordinates. This is a step towards fixing #44, and is in accordance with the principles laid out there, but not the exact syntax proposed there since it was found to be impractical. Also fixes #11. 1. Introduce the `Coordinate` type for individual coordinates. Validate arguments and fail early. 2. Introduce `EmptyLine` for jumps/scanlines. This addresses #11. 3. Rewrite `Coordinates` to contain the above. (`<: OptionType` was removed, because it has no options). 4. Convenience constructors for creating coordinates from vectors, matrices, iterable objects, with or without error bars. Docstrings for the API. 5. Add examples of all the new syntax to the gallery (some of this should be moved to the documentation eventually, that will come later after other changes). 6. 2D histograms now work (example will be added later, when `Table` are redesigned similarly). * Fixed missing packages in REQUIRE. * small formatting changes
I have the same problem, but in my case, my x,y, are not easily to be formed in a table. Is there any solution for x, y, z , which are all matrix , so that it is accepted by surface plot ? |
@CarolinGao12 : please provide a minimal working example. There is a Table([options], ::AbstractVector, ::AbstractVector, ::AbstractMatrix; ...) constructor (implemented by |
it seems the x, y input should be a vector , and z can be a matrix
|
So perhaps we should add:
giving
But what if both |
thanks, I change the matrix to the vector and this problem solved |
using PGFPlotsX
@pgf Plot3({ surf, shader = "interp" },
Table([:x => vec([1 1; 2 2]),
:y => vec([1 2; 1 2]),
:z => vec([1 2; 3 4])],
scanlines = 2))
pgfsave("/tmp/regular.png", ans)
@pgf Plot3({ surf, shader = "interp" },
Table([:x => vec([1 1; 1 2]),
:y => vec([1 2; 2 2]),
:z => vec([1 2; 3 4])],
scanlines = 2))
pgfsave("/tmp/irregular.png", ans) I don't think we should add a constructor for this, as it would just be confusing. |
This would require a method for Coordinates that takes
x
,y
, andz
wherez
is a matrix such thatsize(z,1)==length(x)
andsize(z,2)==length(y)
The text was updated successfully, but these errors were encountered: