Closed Mishrakishan closed 1 year ago
Hello @Mishrakishan, will you be able to share with us the plots that you obtained? Thank you!
Thank you for your response. @swapneelap Certainly, fo this particular plot the codes are: %matplotlib inline field_read = df.Field.fromfile('/Users/kishi/Desktop/DW_DiscreteR100nm_loop6x.out/m000055.ovf')
import matplotlib.pyplot as plt from matplotlib import style style.use('seaborn-white') fig, ax = plt.subplots(figsize=(9, 7), dpi=100) # Increased dpi value for better quality field_read.z.plane('z').mpl(ax=ax, scalar_kw={"cmap": "bwr", "interpolation": "spline16", "colorbar": False,"colorbar_label": "Magnetization ($\mathbf{M_z}$)" }, vector_kw={ "color": "black", "use_color": False, "color_field": field_read.plane('z').x, }, multiplier=1e-6, )
I have used field_read.z.plane('z'). because field_read.plane('z') only giving a black screen. I have attached a sample ovf file of the same.
Although with some cell discretisation, I'm able to get the arrows, but then the layout of the arrows is completely haywire. I tried modifying the arrow scale and size, that didn't work well.
Hello @Mishrakishan, many thanks for attaching the ovf
file. I had a look at it and the code for plotting. The black screen that you see is actually the high density of arrows being plotted corresponding to the projection of magnetization vector in the xy
-plane. The solution is to plot the scalar
and the vector
plots separately, and resample the vector plot to show less number of arrows, as follows:
fig, ax = plt.subplots(figsize=(9, 7))
field.plane("z").z.mpl.scalar(
ax=ax, filter_field=field.norm, colorbar_label="z-component"
)
field.plane("z", n=(90, 90)).mpl.vector(
ax=ax, use_color=False, color="black"
)
You can read more about combining the scalar
and vector
plots in the documentation here. If this solves your problem, please close the issue.
Thank you for the clarification @swapneelap. I have been doing this but this way it takes time to calibrate for a fine value of grid points n that will provide the corresponding plot with both the scalar and vector adjusted well. Thank you, this surely helps.
I will close the issue anyway. just had one more query how do I save a K3D scalar or vector plot (not a screenshot or HTML one) as a PDF or tiff or whatever but with good quality after I have supposedly aligned the camera and axis as per my requirement? This would help a lot.
For example, for the following random code:
import micromagneticdata as md
import k3d
field.plane("z").z.k3d.scalar(cmap = "bwr", interpolation = "spline16", filter_field=field_read.norm, colorbar_label="z-component")
Many thanks for the quick responses.
Hi, Thank you for developing Ubermag. I have generated a series of ovf files from mumax3 for a device structure. I tried to post-process the simulated ovf file on ubermag. I have successfully read the ovf file but while making a vector plot using mpl or k3d, there seems some glitch.
Most of the time there are no vector-only scalar plots. I tried to create a similar mesh to that of mumax3 but it takes a huge amount of time to run. What is the process to plot a compatible scalar and vector plot together that is compatible with ovf file.
A script of code I've taken from the documentation:
The scalar plot seems fine but the vector plot is strongly overlapped and haphazard. Thank you!