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
How to show scalars as categories with a scalar bar (and how to move labels of an axis to the other side) #381
Comments
This is great! The axes are what I want and I think showing a grid makes it even better. I am looking forward to seeing the implementation of the categories. With that, I think vedo surely does all the things that I can do using Paraview but much better and neater! Thanks very much for your always helpful reply. |
Have you by chance upgraded your mac OS? the other problem is bacause you cut/crop the polygonal mesh coming from the tets faces, not the original tets. |
I have not upgraded my OS but I am probably going to do that this weekend. Got tons of unfinished tasks opened and do not want to close them for now... And you are right, I need to cut the TetMesh object rather than the mesh object. And here is what I got Oh, how did you get the scalar bar vertical? I tried to put add vertical=True and it complains that it is not a recognized parameter... This is getting really cool! Thanks a bunch @marcomusy |
Looks great :) you already found how to do it! I was planning to push a new vedo version later which would include a few fixes, including the vertical scalarbar. |
Yes. I tried really hard not to ask you for the code. I looked at that example and figured out how to do it by trial-and-error. I am going to try some vector plots later which I used Paraview Catalyst to create the original version. May need to bug you further there... |
Here we are... upgrade vedo from the master then: import vedo
vedo.settings.defaultFont = 'Kanopus'
vedo.settings.multiSamples = 8 # antialiasing
tet = vedo.TetMesh('data/chddem/final_mesh.1.vtk')
conductor = tet.clone().threshold('cell_scalars', above=0, below=4)
tet.threshold('cell_scalars', above=0, below=15)
# Crop the entire mesh
box = vedo.Box(size=[503500, 505000, 6414000, 6417000, -1830, 600])
tet.cutWithMesh(box, wholeCells=True)
# Crop the conductor mesh
box = vedo.Box(size=[503500, 505200, 6414000, 6417000, -1830, 600])
conductor.cutWithMesh(box)
# We need to build a look up table for our color bar
lut_table = [
#value, color, alpha, category_label
( 0.0, 'black', 1, "\alpha_0"),
( 1.0, 'cyan', 1, "\beta_1"),
( 2.0, 'skyblue', 1, "\Gamma_2"),
( 3.0, 'dodgerblue', 1, "\delta_3"),
( 4.0, 'blue', 1, "\epsilon_4"),
( 5.0, 'gray', 1, "level^5"),
( 6.0, 'yellow', 1, "level^6"),
( 7.0, 'gold', 1, "level^7"),
( 9.0, 'red', 1, "level^8"),
(11.0, 'powderblue', 1, "level^9"),
(13.0, 'lime', 1, "level^10"),
(15.0, 'seagreen', 1, "level^11"),
]
lut = vedo.buildLUT(lut_table)
msh = tet.tomesh().lw(1).lc('white')
msh.cmap(lut, 'cell_scalars', on='cells')
msh.addScalarBar3D(
categories=lut_table,
pos=(505800, 6415500, -1830),
title='Units',
titleSize=1.25,
sx=100,
sy=2200,
)
# put scalarbar vertical and shift it up a bit
msh.scalarbar.rotateX(90, locally=True).rotateY(45, locally=True).shift(-300,1400,1200)
# Create cmap for cond
cond = conductor.tomesh().cmap(lut, 'cell_scalars', on='cells')
axes = vedo.Axes(msh + cond,
xtitle='Easting (m)',
ytitle='Northing (m)',
ztitle='Elevation (m)',
xTitlePosition=0.65,
yTitlePosition=0.65,
zTitlePosition=0.65,
zTitleOffset=0.04,
axesLineWidth=3,
gridLineWidth=2,
yTitleOffset=-0.22,
yShiftAlongX=1,
yLabelRotation=90,
yLabelOffset=-1.5,
tipSize=0,
yzGrid=True,
xyGridColor='k',
xyFrameLine=True,
)
plt = vedo.Plotter(size=(1565, 1350))
plt.camera.SetPosition( [512150.624, 6410616.074, 4432.376] )
plt.camera.SetFocalPoint( [504505.154, 6415331.728, -815.481] )
plt.camera.SetViewUp( [-0.413, 0.29, 0.863] )
plt.camera.SetDistance( 10403.394 )
plt.show(msh, cond, axes, resetcam=False, zoom=1.3) Let me know if you have any questions. Please star the project if you find it useful and if you publish anything that leverages |
Just wonderful! I can now replace the original ugly figure that I included in my manuscript with this fancy one now. I stared the project and will send you the paper later once it is published. I will be returning the revised manuscript next week and am expecting it to be published soon (finally moderate revision this time). I am actually preparing a presentation for our group meeting tomorrow on this very topic. I will include this fancy picture and the code used to create this in the presentation and I am pretty sure everyone is going to like this. As far as I know, almost everyone in our group needs to use Inkscape to edit figures created using Paraview simply for making better looking axes labels. Thanks very much. |
May cite this as well with |
I'm glad you like it ! Keep in mind that you can reshuffle the ordering of colors and labels in scalarbar by chnging the lut_table list (by makiing a copy), if needed. |
cool!
so the line the only other thing that looks a bit strange is that the axes grid lines are less visible than in my case, maybe because you're making the whole image bigger. In case you can play with the grid opacity and grid line width. |
Sorry, my bad. I forgot to include that line there. But wouldn't it be better just to make that the default behavior? Also, increasing the gridLineWidth does make the grid lines more visible, which is good. Thanks for pointing this out. I was not even aware of that. |
as vtk9 is quite buggy, making it the default might not be possible. Actually can you try from command line: |
Oh, okay, I have no idea about anything related to vtk. Tried that thing and yep the volume disappeared in no time! |
Is there a way to control the size of the labels of a scalar bar? I think I can control the size of the title but there is nothing specifying how large is the label for the scalar bar. |
ok, that's a vtk9 bug.. it should not disappear, a added a check to disable antialiasing for volumes scenes on OSX.
I forgot to add it! In the master version (just pushed it) you can find |
I am not sure how this is supposed to work. But would I be able to get the newest code by using Or, should I clone the repository to my computer? Have been using svn forever and don't really know much about Git or Github in general. |
yes: |
The manuscript I mentioned earlier that uses vedo has been accepted for publish. I have finished proofreading and the journal should be able to put the final version up on their website soonish. But here is a link to the paper on the journal's website as of now: https://library.seg.org/doi/10.1190/geo2020-0657.1 I might remember to update the link after the final version appears on the website. The paper cited vedo and acknowledged your help in the end. Once again, thanks for making vedo available to us and for all the help you provided along the way. Hopefully, more people from the geophysics community could see the potential of what vedo can do in plotting all the Earth models when they read my paper. |
Congratulations for the publication! I'll add the paper info to the current list of papers leveraging the package |
What an amazing module! Additionally, is there a list of keystrokes somewhere in the documentation? The Shift-A advocacy is the first I've heard of this, but I'm very new! Thank you! |
Thanks Phil! At the moment the category feature is limited to scalarbar3d, the 2d one is in my todo list! |
Two issues here related to the following plot:
Here is the code I used to plot the figure:
The vtk file used to plot the figure:
final_mesh.1.vtk.zip
Thanks in advance for any comments and suggestions!
The text was updated successfully, but these errors were encountered: