Replies: 15 comments 1 reply
-
I'm not sure if plotting complex numbers actually makes sense, what one usually do is to plot either the real/imaginary parts, or the modulus/argument separately |
Beta Was this translation helpful? Give feedback.
-
If I give a single vector of complex numbers as argument, I expect it to be plot on the complex plane(real part vs imaginary part) (with the axes getting displayed properly) THANKS FOR RESPONDING! |
Beta Was this translation helpful? Give feedback.
-
I think that's why complex number are not supported directly : depending on the application people expect different results ^^ In your first case you can do And in your second |
Beta Was this translation helpful? Give feedback.
-
Figured that out |
Beta Was this translation helpful? Give feedback.
-
Well, there isn't a problem, as long as the behavior depends on the type! |
Beta Was this translation helpful? Give feedback.
-
why not use function overloading? end |
Beta Was this translation helpful? Give feedback.
-
Yeah, that's an option: |
Beta Was this translation helpful? Give feedback.
-
Is there more detailed documentation for convert_arguments(::Type{<:Scatter}, x::Complex) = (real(x), imag(x),) but I wasn't able to get a call like |
Beta Was this translation helpful? Give feedback.
-
Well, if you want to plot a vector of complex number, you need to overload the conversion for a vector of complex numbers. function convert_arguments(::Type{<:Scatter}, numbers::AbstractVector{<: Complex})
return (map(x-> Point2f0(real(x), imag(x)), numbers),)
end |
Beta Was this translation helpful? Give feedback.
-
Thanks so much! I assumed this was recursive. |
Beta Was this translation helpful? Give feedback.
-
For further reference, I used convert_arguments(::Type{<:Scatter}, coords::AbstractVector{<:Complex}) = (map(x -> Point2(float(real(x)), float(imag(x))), coords),)
convert_arguments(::Type{<:Scatter}, coords::AbstractVector{<:Complex}, heights::AbstractVector{<:Real}) = (map((x, z) -> Point3(float(real(x)), float(imag(x)), float(z)), coords, heights),) |
Beta Was this translation helpful? Give feedback.
-
I second the request for built-in support for plotting complex numbers. I'm new to Julia, and decided to try it out specifically for its typing system, but have found it extremely difficult to use so far in practice. Ideally, I would be able to pass in an array of complex numbers and have them plotted in the complex plane. For example, I would like to use something like |
Beta Was this translation helpful? Give feedback.
-
Maybe someone can turn those converts into a PR? :) |
Beta Was this translation helpful? Give feedback.
-
@Uroc327 Can you make the PR? |
Beta Was this translation helpful? Give feedback.
-
I'd also like to second the vote for this. I use complex numbers often because they make bivariate data (e.g. horizontal velocity or displacement) quite simple. For complicated plots writing real(z),imag(z) many times becomes tedious. Naturally when you write a complex number you mean z = x + im y, so it's natural to expect that behavior. ... And if someone has the patience to explain to a Julia newbie what I need to do to take advantages of the changes Uroc327 made, I would greatly appreciate it. |
Beta Was this translation helpful? Give feedback.
-
Makie.jl doesn't support complex numbers for data, yet?
Is there a way to plot a 100 x 2 data of complex numbers?
Beta Was this translation helpful? Give feedback.
All reactions