Skip to content

Commit

Permalink
fixes to /src/compat/pyplot.jl to work with more recent matplotlib ve…
Browse files Browse the repository at this point in the history
…rsions
  • Loading branch information
thchr committed Oct 20, 2021
1 parent 6a7b568 commit bd4b8a3
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/compat/pyplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ORIGIN_MARKER_OPTS = (marker="o", markerfacecolor="white", markeredgecolor

function plot(Rs::AbstractBasis{D},
cntr::SVector{D, <:Real}=zeros(SVector{D, Float64}),
ax=plt.figure().gca(projection = D==3 ? (using3D(); "3d") : "rectilinear")) where D
ax=plt.axes(projection = D==3 ? (using3D(); "3d") : "rectilinear")) where D

Rs′ = Rs .+ Ref(cntr) # basis vectors translated by cntr

Expand Down Expand Up @@ -46,7 +46,7 @@ function plot(Rs::AbstractBasis{D},
ax.set_xlabel("x"); ax.set_ylabel("y")
# seems broken in 3D (https://github.com/matplotlib/matplotlib/pull/13474);
# FIXME: may raise an error in later matplotlib releases
ax.set_aspect("equal", adjustable="box")
# ax.set_aspect("equal", adjustable="box")
return ax
end

Expand Down Expand Up @@ -101,7 +101,7 @@ function plotiso(xyz, vals, isoval::Real, Rs::DirectBasis{D},
else
fig.clf()
end
ax = fig.gca(projection= D==3 ? (using3D(); "3d") : "rectilinear")
ax = fig.add_subplot(projection= D==3 ? (using3D(); "3d") : "rectilinear")

if D == 2
# convert to a cartesian coordinate system rather than direct basis of Ri
Expand Down Expand Up @@ -247,10 +247,10 @@ end

# ::KVec ----------------------------------------------------------------------------------

# Plotting a single `KVec`
function plot(kv::KVec,
ax=plt.figure().gca(projection = dim(kv)==3 ? (using3D(); "3d") : "rectilinear"))
D = dim(kv)
# Plotting a single `KVec` or `RVec`
function plot(kv::AbstractVec{D},
ax=plt.axes(projection = D==3 ? (using3D(); "3d") : "rectilinear")) where D

freeαβγ = freeparams(kv)
nαβγ = count(freeαβγ)
nαβγ == 3 && return ax # general point/volume (nothing to plot)
Expand Down Expand Up @@ -285,12 +285,11 @@ function plot(kv::KVec,
return ax
end

# Plotting a vector of `KVec`s
function plot(kvs::AbstractVector{KVec})
D = dim(first(kvs))
ax = plt.figure().gca(projection= D==3 ? (using3D(); "3d") : "rectilinear")
for kv in kvs
plot(kv, ax)
# Plotting a vector of `KVec`s or `RVec`s
function plot(vs::AbstractVector{<:AbstractVec{D}}) where D
ax = plt.axes(projection= D==3 ? (using3D(); "3d") : "rectilinear")
for v in vs
plot(v, ax)
end
return ax
end
Expand Down

4 comments on commit bd4b8a3

@thchr
Copy link
Owner Author

@thchr thchr commented on bd4b8a3 Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register subdir=Bravais

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/47099

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a Bravais-v0.1.1 -m "<description of version>" bd4b8a33828ac59c048a5f639d16ecb4db11a1ac
git push origin Bravais-v0.1.1

@thchr
Copy link
Owner Author

@thchr thchr commented on bd4b8a3 Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/47105

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.10 -m "<description of version>" bd4b8a33828ac59c048a5f639d16ecb4db11a1ac
git push origin v0.4.10

Please sign in to comment.