Any way to invert legend colors?

In \Tools\Options\Contour plot\Custom\Custom colors I have my legend colors set as --



The following image shows a static analysis where the top surface of the cylinder is fixed and a negative pressure is applied to the bottom surface (the stud). This causes elongation in the negative direction as shown in the legend.



Generally, hot colors are used to indicate a large effect whereas cool colors indicate a small effect. In this case the colors are reversed so that red indicates near-zero displacement and dark purple indicates maximum displacement. I'm looking for some way to easily invert the colors. Taking the absolute value of the displacements gives the desired color distributions but then the legend is wrong since all displacement values are indicated as positive (next image). (Re-editing \Tools\Options\Contour plot\Custom\Custom colors isn't really an option since this takes too much time and then interferes with "normal" legends.)



If there's no easy way to do this then perhaps an "Invert legend colors" option could be added to \Solution\Deformed view settings.

Comments

  • edited July 2022
    Hi dculp,

    I would rotate the whole model 180º.
  • disla -- That wouldn't be the way the part is located in physical space (then it would be upside down). However, I would use this method if no other easy options.
  • Ansys apparently allows this (https://forum.ansys.com/forums/topic/interference-fit-pressure/) unless the legend colors were manually inverted. (The model is for an interference fit.)


  • Hi dculp,

    There is a way to do this. My first response was probably too precipitated as sorted the problem immediately but for a more permanent solution you could create a custom color legend and save it inside the default model folder to be loaded automatically each time you create a new file. The “Custom” legends would contain the “Reversed colors” and will be saved permanently.
    Custom file needs to be created in case you haven't. Tell Mecway the folder in Tools/Options/Defaults.

    To invert the colors, edit the “Options/Contour Plot/Custom” colors. Delete any colors in case you have changed previously something and press ok.
    Reopen “Custom” and you will have the standard range again. Use the up and down arrows to sort them upside down.
    Press ok and save the file as Default.

    Next time you create a file , Custom contour plot will contain the reversed color range.


  • disla --

    This works --



    However, it has a major shortcoming (as far as I can determine). Once this inverted color scheme is created, it is applied to all models. However, the original (non-inverted) color scheme may be desired for some models. In this case the inverted color scheme must itself be inverted to get back to the original color scheme; then the inverted color scheme is lost.

    In what file are the legend colors stored? Then two different versions of this file could be saved, one with the normal colors and one with the inverted colors. Then either of these files could be renamed to become the active color file. Alternately, the colors section of this file could be copied-pasted as needed for the normal or inverted colors.
  • edited September 2022
    I propose to store the inverted scheme in the Custom Colors. Last option below ....., Red-Blue, Grey Scale. This doesn't mean it has to be the default. You can keep the Rainbow as usual and switch to custom depending on your needs. I have created a beautiful custom Palette in Custom for whenever I feel..... inspired. :D
    In what file are the legend colors stored?
    Tools/Options /Defaults
    Then two different versions of this file could be saved
    That's another option. You could create as much custom palettes as you want the same as different systems units , .... We could even share Colour schemes. I have not try but maybe it can be imported.

    Regards


  • disla --

    Your suggestion might work in some cases. However, I don't use the Rainbow for certain reasons. Instead, my "normal" colors are already customized and saved as Custom. Thus, what I need is two custom configurations -- normal and inverted.

    I now remember that the colors are stored in user.config (in my case "C:\Users\HP\AppData\Local\Mecway_Limited\mecway.exe_StrongName_srenxo1oihmv3emikwtooe35mfwix3fi\16.0.8251.18890\user.config"). The custom colors there are --

    <setting name="CustomColors" serializeAs="Xml"> <value> <ArrayOfColorListColor xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ColorListColor> <StringValue>#3A0073</StringValue> </ColorListColor> <ColorListColor> <StringValue>#3A0073</StringValue> </ColorListColor> <ColorListColor> <StringValue>#6419FF</StringValue> </ColorListColor> <ColorListColor> <StringValue>#6419FF</StringValue> </ColorListColor> <ColorListColor> <StringValue>#00C8C8</StringValue> </ColorListColor> <ColorListColor> <StringValue>#00C8C8</StringValue> </ColorListColor> <ColorListColor> <StringValue>#417800</StringValue> </ColorListColor> <ColorListColor> <StringValue>#417800</StringValue> </ColorListColor> <ColorListColor> <StringValue>#5BAC00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#5BAC00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#96BB00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#96BB00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#F1F800</StringValue> </ColorListColor> <ColorListColor> <StringValue>#F1F800</StringValue> </ColorListColor> <ColorListColor> <StringValue>#E79F00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#E79F00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#DF5600</StringValue> </ColorListColor> <ColorListColor> <StringValue>#DF5600</StringValue> </ColorListColor> <ColorListColor> <StringValue>#FF0000</StringValue> </ColorListColor> <ColorListColor> <StringValue>#FF0000</StringValue> </ColorListColor> </ArrayOfColorListColor> </value> </setting>

    My default liml file (E:\Data\Mecway\Library\Modal_default_1.liml) has --

    <liml version="15"> <analysis type="V30" solver="ccx" maxmode="5" /> <elset name="Default" color="-6710887" expanded="true" material="Material_set_mm_units" /> <mat name="Material_set_mm_units"> <geometric type="Plate" thickness="1 mm" /> <mechanical type="Isotropic" youngsmodulus="1 MPa" /> <density type="Simple" density="1 kg/m³" /> </mat> <formula name="Displacement_z[m]" displayunit="" fieldscalar="displacement_z[m]"> <unit exponents="+1">mm</unit> <formula>abs(u.z)/1.0</formula> </formula> <formula name="Displacement_x[m]" displayunit="" fieldscalar="formula"> <unit exponents="+1">m</unit> <formula>abs(u.x)/1.0</formula> </formula> <formula name="Displacement_y[m]" displayunit="" fieldscalar="formula(2)"> <unit exponents="+1">m</unit> <formula>abs(u.y)/1.0</formula> </formula> <formula name="Displacement_magnitude[m]" displayunit="" fieldscalar="formula(4)"> <unit exponents="+1">m</unit> <formula>sqrt(u.x^2 + u.y^2 + u.z^2)/1.0</formula> </formula> <formula name="Displacement_r[m]" displayunit="" fieldscalar="displacement_r[m]"> <unit exponents="+1">m</unit> <formula>abs( x*u.x + y*u.y ) / (sqrt(x^2+y^2) +1e-10)</formula> </formula> <formula name="Displacement_theta[m]" displayunit="" fieldscalar="displacement_t[m]"> <unit exponents="+1">m</unit> <formula>abs( x*u.y - y*u.x ) / (sqrt(x^2+y^2) +1e-10) </formula> </formula> <formula name="von_Mises_per_micron_peak" displayunit="" fieldscalar="formula(3)"> <unit exponents="-1+1-2">MPa</unit> <formula>vm/(1e6)</formula> </formula> <fieldvariable name="von Mises stress" displayunit="MPa" /> <fieldvariable name="displacement" displayunit="mm" expanded="true" /> <fieldvariable name="stress" displayunit="MPa" /> <solution> <analysis type="S30" solver="ccx" /> <elset name="Default" color="-6710887" expanded="true" /> </solution> </liml>

    I don't see where the default liml file references the user.config file in order to pick up the custom colors in user.config.
  • Oh, so you have the custom palette already in use as default.
    mhh :#
  • The custom colors are stored in "C:\Users\HP\AppData\Local\Mecway_Limited\mecway.exe_StrongName_srenxo1oihmv3emikwtooe35mfwix3fi\16.0.8251.18890\user.config" under
    <setting name="CustomColors" serializeAs="Xml">.

    The custom colors apparently have no relation to "\Tools\Options\Defaults\.liml file" -- i.e., if this path is removed the custom colors are still displayed.

    To create an inverted legend I created two color sets and then used the desired one as needed --
    1. Open Mecway and then "\Tools\Options\Contour plot". Set the desired "Number of colors".
    2. Under "Custom" change colors as desired. This will be called the Normal color set.
    3. Exit Mecway. The colors will be immediately saved in user.config under <setting name="CustomColors" serializeAs="Xml">.
      For example, my Normal color set is --
      <setting name="CustomColors" serializeAs="Xml"> <value> <ArrayOfColorListColor xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ColorListColor> <StringValue>#3A0073</StringValue> </ColorListColor> <ColorListColor> <StringValue>#3A0073</StringValue> </ColorListColor> <ColorListColor> <StringValue>#6419FF</StringValue> </ColorListColor> <ColorListColor> <StringValue>#6419FF</StringValue> </ColorListColor> <ColorListColor> <StringValue>#00C8C8</StringValue> </ColorListColor> <ColorListColor> <StringValue>#00C8C8</StringValue> </ColorListColor> <ColorListColor> <StringValue>#417800</StringValue> </ColorListColor> <ColorListColor> <StringValue>#417800</StringValue> </ColorListColor> <ColorListColor> <StringValue>#5BAC00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#5BAC00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#96BB00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#96BB00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#F1F800</StringValue> </ColorListColor> <ColorListColor> <StringValue>#F1F800</StringValue> </ColorListColor> <ColorListColor> <StringValue>#E79F00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#E79F00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#DF5600</StringValue> </ColorListColor> <ColorListColor> <StringValue>#DF5600</StringValue> </ColorListColor> <ColorListColor> <StringValue>#FF0000</StringValue> </ColorListColor> <ColorListColor> <StringValue>#FF0000</StringValue> </ColorListColor> </ArrayOfColorListColor> </value> </setting>
      Note that the colors are listed in reverse order compared to how they are displayed in the legend. Thus, the first listed color (#3A0073; dark purple) is displayed at the bottom of the legend and the last listed color (#FF0000; bright red) is displayed at the top of the legend.
    4. Open user.config with a text editor.
      Save just the above section between <setting name="CustomColors" serializeAs="Xml">..</setting> for later use. I saved as Contour_custom_colors__normal.xml. (The xml extension isn't required. It could also be txt or whatever is convenient.)
    5. Open Mecway and then "\Tools\Options\Contour plot\Custom". You will see the colors above.
    6. You should now invert the colors. Click on the last color. Using the up arrow, move it to the top. Click on the newest last color and move it 1 step below the top. Repeat until all of the colors have been inverted. This will be called the Inverted color set.
    7. Exit Mecway. The Inverted colors will be immediately saved in user.config under <setting name="CustomColors" serializeAs="Xml">. The Inverted colors will overwrite the previous Normal colors. For example, the Inverted color set becomes --
      <setting name="CustomColors" serializeAs="Xml"> <value> <ArrayOfColorListColor xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ColorListColor> <StringValue>#FF0000</StringValue> </ColorListColor> <ColorListColor> <StringValue>#FF0000</StringValue> </ColorListColor> <ColorListColor> <StringValue>#DF5600</StringValue> </ColorListColor> <ColorListColor> <StringValue>#DF5600</StringValue> </ColorListColor> <ColorListColor> <StringValue>#E79F00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#E79F00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#F1F800</StringValue> </ColorListColor> <ColorListColor> <StringValue>#F1F800</StringValue> </ColorListColor> <ColorListColor> <StringValue>#96BB00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#96BB00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#5BAC00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#5BAC00</StringValue> </ColorListColor> <ColorListColor> <StringValue>#417800</StringValue> </ColorListColor> <ColorListColor> <StringValue>#417800</StringValue> </ColorListColor> <ColorListColor> <StringValue>#00C8C8</StringValue> </ColorListColor> <ColorListColor> <StringValue>#00C8C8</StringValue> </ColorListColor> <ColorListColor> <StringValue>#6419FF</StringValue> </ColorListColor> <ColorListColor> <StringValue>#6419FF</StringValue> </ColorListColor> <ColorListColor> <StringValue>#3A0073</StringValue> </ColorListColor> <ColorListColor> <StringValue>#3A0073</StringValue> </ColorListColor> </ArrayOfColorListColor> </value> </setting>
      Reload user.config in your text editor. Then save just the above section for later use. I saved as Contour_custom_colors__inverted.xml.
    8. Now, whenever you know that you will need to change the order of the colors in the legend box, then open user.config before you start Mecway. Find the code between <setting name="CustomColors" serializeAs="Xml">..</setting> and replace it with the alternate custom color code that you had previously saved. For example, if the current colors are Normal, then just replace these Normal colors with Inverted (e.g., the code that you had previously saved in Contour_custom_colors__inverted.xml). When you start Mecway, these new colors will be displayed for every model until you exit Mecway and restore the original Normal colors (e.g., from Contour_custom_colors__normal.xml).
    9. As an alternate method, you could put both sets of colors in user.config and then rename the one that you don't want to use. For example, if you don't want to use the Normal color set then rename its color set from <setting name="CustomColors" serializeAs="Xml"> to <setting name="ZCustomColors" serializeAs="Xml">. Note that only one color set can be named <setting name="CustomColors" serializeAs="Xml">; all others must have some other temporary name. (See the attached file. Search to find CustomColors and ZCustomColors.)
    10. In fact, you could make any number of color schemes with the above method. For example, you could have an alternate gray-scale that you could save as Contour_custom_colors__gray_scale.xml.
    Very important -- user.config should only be edited when Mecway is not loaded. Otherwise, when Mecway exits it will overwrite any changes that you have made to user.config.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!