TransWikia.com

How to color a plot with a vector

Mathematica Asked on September 3, 2021

Suppose I have four dimensional data, i.e. at each point in the plane, I have two numbers associated with it. For example, {{{1,1},{f[1,1],g[1,1]}},{{1,2},{f[1,2],g[1,2]}},...}. My data would not make sense to plot as a vector field. Instead, I would like to color each point, where its darkness corresponds to the size of f, and its hue corresponds to g. So at the end of the day, it would look like a ContourPlot, where the ColorFunction takes the function values as input.

Any help is greatly appreciated!

One Answer

Here is a solution that seems to work:

customColor[xx_, yy_] := 
 Blend[{Hue[0, 1, yy], Hue[0.2, 1, yy], Hue[0.4, 1, yy], 
   Hue[0.6, 1, yy], Hue[0.8, 1, yy]}, xx]
dataTest = { {1, 1, 0.1, 0.3}, {1, 2, 1, 1}, {2, 1, 0.5, 0.1}, {2, 2, 
    0.7, 0}};
Graphics[{customColor[#3, #4], Rectangle[{#1, #2}]} & @@@ dataTest, 
 Frame -> True]

Correct answer by David on September 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP