|
[Sponsors] |
December 1, 2015, 12:29 |
Colorbar position
|
#1 |
New Member
VladJ
Join Date: Feb 2012
Location: Belgium
Posts: 18
Rep Power: 14 |
Dear all,
After many trials to solve this problem, even within the recorded python script, i could not make the location of the colorbar to be the same for all the variables. Has anybody ever had an experience with this issue? Thanks in advance. |
|
December 8, 2015, 04:27 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Quick question: Can you provide some example data and the python code you're trying to use for manipulating the scalar bars?
I ask this because I've done something like that in the past, but it was a pure clone of an existing render view, which means that I was already copying all of the existing data for an identical scalar bar and not between two different, but similar scalar bars. Therefore, having some code to base myself on, I should be able to make the final adjustments you're missing. Either way, the code I had for cloning the scalar bars was this: Code:
#Need a dummy scalar bar for reference dummyScalarBar = CreateScalarBar() # Copy scalar bar configurations for repItem in referenceView.Representations: if type(repItem) == type(dummyScalarBar): newDisplay = CreateScalarBar() renderViewSandBox.Representations.append(newDisplay) # transfer options for prop in repItem.ListProperties(): if not prop.endswith("Info") and \ not prop.startswith("Select"): #print prop setattr(newDisplay, prop, getattr(repItem, prop)) Delete(dummyScalarBar) del dummyScalarBar |
|
April 26, 2016, 12:30 |
Colorbar location
|
#3 |
New Member
VladJ
Join Date: Feb 2012
Location: Belgium
Posts: 18
Rep Power: 14 |
Dear Bruno,
I am very sorry for the super late reply to your answer. Here is a sample python recording of a basic cavity case with icoFoam. What I would like to achieve is to have the colormap position at the same location for different variables. The reason to do this is that I often make presentations where I place figures of the same variable on many consecutive slides to show how field changes while changing turbulence models or something like that. So if you scroll through the presentation it would be nice if the colormap and geometry stay at the same location and do not jump around so you can actually focus on how pressure or velocity field change. Apart from this line in python trace which refers to the colormap I haven't found any other function which can anchor its location. Code:
# show color bar/color legend controlDictDisplay.SetScalarBarVisibility(renderView1, True) Cheers! |
|
April 28, 2016, 04:04 |
|
#4 |
Senior Member
|
Hi,
I managed to have a similar issue this week and kind of got a workaround for ParaView 5.0.0. (at the bottom of this post). I say "kind of" because I used the code below for more than 1 variable and the result for one of the variables is different for some reason I could not yet understand. Anyhow, the logic below is used to create a scalar bar for kMean that is horizontal and centered around the center of the figure on the lower part of the figure. Your command only specifies whether the scalarbar is visible or not, to actually control it, you should register the scalarbar as an object, which is done by this line: Code:
scalarBarkMeanLUT = GetScalarBar(kMeanLUT, renderView1) The position2 part specifies the fraction of the window that the top right part of the scalarbar should be away from the lower left part. So in my example, the lower left point of the scalar bar is at 30% window width from the left edge of the window, and 3.5% window height from the bottom of the window. The right edge of the scalar bar is 40% window width further from the 30% window width (so at 70% window width from the left edge). Since the orientation is Horizontal, the Aspect ratio actually determines where the top of the scalarbar is with respect to a fraction of the window height. So the behavior is a bit different depending on the orientation of the scalarbar, but I hope this gives you the general idea. Code:
# get color transfer function/color map for 'kMean' kMeanLUT = GetColorTransferFunction('kMean') kMeanLUT.NanColor = [0.0, 1.0, 0.0] kMeanLUT.ScalarRangeInitialized = 1.0 # get opacity transfer function/opacity map for 'kMean' kMeanPWF = GetOpacityTransferFunction('kMean') kMeanPWF.Points = [0, 0.0, 0.5, 0.0, 100, 1.0, 0.5, 0.0] kMeanPWF.ScalarRangeInitialized = 1 # get color legend/bar for kMeanLUT in view renderView1 scalarBarkMeanLUT = GetScalarBar(kMeanLUT, renderView1) scalarBarkMeanLUT.Position = [0.3, 0.035] scalarBarkMeanLUT.Position2 = [0.7, 0.12] scalarBarkMeanLUT.Orientation = 'Horizontal' scalarBarkMeanLUT.Position = [0.3, 0.035] scalarBarkMeanLUT.Position2 = [0.7, 0.12] scalarBarkMeanLUT.ComponentTitle = '' # Properties modified on scalarBarkMeanLUT scalarBarkMeanLUT.Title = 'k [$m^2/s^2$]' scalarBarkMeanLUT.TitleColor = [0.0, 0.0, 0.0] scalarBarkMeanLUT.LabelColor = [0.0, 0.0, 0.0] scalarBarkMeanLUT.RangeLabelFormat = '%6.3g' # Rescale transfer function kMeanLUT.RescaleTransferFunction(0.0, 100.0) kMeanPWF.RescaleTransferFunction(0.0, 100.0) Regards, Tom |
|
April 28, 2016, 04:41 |
|
#5 |
New Member
VladJ
Join Date: Feb 2012
Location: Belgium
Posts: 18
Rep Power: 14 |
Hello Tom,
thanks for the quick reply. Since this issue is critical for me I will try to test in on some data ASAP. I hope to have to this issue resolved. Cheers and take care. |
|
April 28, 2016, 09:56 |
|
#6 |
New Member
VladJ
Join Date: Feb 2012
Location: Belgium
Posts: 18
Rep Power: 14 |
Hello Tom,
I am typing up line by line from your previous post in the Python shell of the Paraview 5.0, however when I get to the Code:
scalarBarkMeanLUT = GetScalarBar(pressure, renderView1) Code:
>>> scalarBarPressure = GetScalarBar(pressure, RenderView1) Traceback (most recent call last): File "<console>", line 1, in <module> NameError: name 'RenderView1' is not defined >>> Cheers and thanks in advance! |
|
April 28, 2016, 11:14 |
|
#7 |
Senior Member
|
Hi,
I have this: Code:
# get active view renderView1 = GetActiveViewOrCreate('RenderView') Regards, Tom |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[OpenFOAM] an error in Calculator's equation | immortality | ParaView | 12 | June 29, 2021 00:10 |
Force dependent on particle position | jranita | OpenFOAM Programming & Development | 1 | August 23, 2011 19:44 |
how to read in a position file | jiejie | OpenFOAM | 0 | May 23, 2011 04:38 |
DPM UDF particle position using the macro P_POS(p)[i] | dm2747 | FLUENT | 0 | April 17, 2009 01:29 |
Combustion Convergence problems | Art Stretton | Phoenics | 5 | April 2, 2002 05:59 |