CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

[General] Colorbar position

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 1, 2015, 12:29
Default Colorbar position
  #1
New Member
 
VladJ
Join Date: Feb 2012
Location: Belgium
Posts: 18
Rep Power: 14
kingeorge is on a distinguished road
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.
kingeorge is offline   Reply With Quote

Old   December 8, 2015, 04:27
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
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
I believe this worked with ParaView 4.1.
wyldckat is offline   Reply With Quote

Old   April 26, 2016, 12:30
Default Colorbar location
  #3
New Member
 
VladJ
Join Date: Feb 2012
Location: Belgium
Posts: 18
Rep Power: 14
kingeorge is on a distinguished road
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)
Thank you very much in advance for any response on this issue.


Cheers!
Attached Files
File Type: zip colormap_position_control_v01.py.zip (2.3 KB, 13 views)
kingeorge is offline   Reply With Quote

Old   April 28, 2016, 04:04
Default
  #4
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 634
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
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 position is controlled basically using the position and the position2 parts. The position part specifies the lower-left point of the scalar-bar as a fraction of the width and height of the complete view [0.0, 0.0] would be lower left corner, [1.0, 1.0] would be upper right corner.

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)
Hope this helps,
Regards,
Tom
tomf is online now   Reply With Quote

Old   April 28, 2016, 04:41
Default
  #5
New Member
 
VladJ
Join Date: Feb 2012
Location: Belgium
Posts: 18
Rep Power: 14
kingeorge is on a distinguished road
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.
kingeorge is offline   Reply With Quote

Old   April 28, 2016, 09:56
Default
  #6
New Member
 
VladJ
Join Date: Feb 2012
Location: Belgium
Posts: 18
Rep Power: 14
kingeorge is on a distinguished road
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)
it gives:

Code:
>>> scalarBarPressure = GetScalarBar(pressure, RenderView1)
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
 NameError: name 'RenderView1' is not defined
 >>> 
Is there anything to define before this line regarding the renderView1?

Cheers and thanks in advance!
kingeorge is offline   Reply With Quote

Old   April 28, 2016, 11:14
Default
  #7
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 634
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
Hi,

I have this:

Code:
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
So probably you would have something similar from your trace as well, use that one!

Regards,
Tom
tomf is online now   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 04:00.