Рубрики

colors

What colors merge to create purple?

A colormap is like a list of colors, where each color has a value that ranges from 0 to 100.


Matplotlib Scatter

With Pyplot, you can use the scatter() function to draw a scatter plot.

The scatter() function plots one dot for each observation. It needs two arrays of the same length, one for the values of the x-axis, and one for values on the y-axis:

Example

A simple scatter plot:

import matplotlib.pyplot as plt
import numpy as np

x = np.array([5,7,8,7,2,17,2,9,4,11,12,9,6])
y = np.array([99,86,87,88,111,86,103,87,94,78,77,85,86])

Result:

The observation in the example above is the result of 13 cars passing by.

The X-axis shows how old the car is.

The Y-axis shows the speed of the car when it passes.

Are there any relationships between the observations?

It seems that the newer the car, the faster it drives, but that could be a coincidence, after all we only registered 13 cars.

Compare Plots

In the example above, there seems to be a relationship between speed and age, but what if we plot the observations from another day as well? Will the scatter plot tell us something else?

Example

Draw two plots on the same figure:

import matplotlib.pyplot as plt
import numpy as np

#day one, the age and speed of 13 cars:
x = np.array([5,7,8,7,2,17,2,9,4,11,12,9,6])
y = np.array([99,86,87,88,111,86,103,87,94,78,77,85,86])
plt.scatter(x, y)

#day two, the age and speed of 15 cars:
x = np.array([2,2,8,1,15,8,12,9,7,3,11,4,7,14,12])
y = np.array([100,105,84,105,90,99,90,95,94,100,79,112,91,80,85])
plt.scatter(x, y)

Result:

Note: The two plots are plotted with two different colors, by default blue and orange, you will learn how to change colors later in this chapter.

By comparing the two plots, I think it is safe to say that they both gives us the same conclusion: the newer the car, the faster it drives.

Colors

You can set your own color for each scatter plot with the color or the c argument:

Example

Set your own color of the markers:

import matplotlib.pyplot as plt
import numpy as np

x = np.array([5,7,8,7,2,17,2,9,4,11,12,9,6])
y = np.array([99,86,87,88,111,86,103,87,94,78,77,85,86])
plt.scatter(x, y, color = ‘hotpink’)

x = np.array([2,2,8,1,15,8,12,9,7,3,11,4,7,14,12])
y = np.array([100,105,84,105,90,99,90,95,94,100,79,112,91,80,85])
plt.scatter(x, y, color = ‘#88c999’)

Result:

nick olsen michael lorber park avenue home tour sitting room

The era of vibrancy is upon us. The nation’s top color experts decree the reign of neutrals and cool tones over. Bold, playful tones leaning on the warmer side of the color wheel are predicted to skyrocket in popularity in 2023. The reason: People are becoming more adventurous with their color choices as a way to express themselves.

Laurie Pressman, vice president of the Pantone Color Institute, explains that it’s not just that people are moving towards using bolder colors, but they are using colors in clever ways—especially in homes. “It’s all about our desire for creative expression,” Pressman says. “Understanding that our surroundings influence our mental health, many are expressing their creativity in the home as a way to enhance their feelings of joyfulness and well-being.”

People no longer fear committing to a gutsy paint color for their dining room or upholstering sofas in prismatic patterns. Instead, they are thinking about how they can mix different color stories together to create a personal space that is completely unique to them. Andrea Magno, color marketing director at Benjamin Moore, further notes that there may be no better way to refresh one’s home than embracing incorporating a more vibrant palette.

“We know that taking a leap into more daring color may not be easy, but once people take the plunge into a color that is either bold, saturated or deep—even in the smallest spaces, they are able to experience the transformational power of color,” says Magno.

While it truly comes down to personal preference when choosing the right shade for you, there are a few color families both Pressman and Magno foresee popping up everywhere in the upcoming year. For those looking for inspiration, these are the six color trends that will be huge in 2023.


How to permanently change a cell’s color based on its current value

Once set, the background color will not change no matter how the cell’s contents might change in the future.

Task: You want to color a cell based on its current value and wish the background color to remain the same even when the cell value’s changes.

Solution: Find all cells with a certain value or values using Excel’s Find All function or Select Special Cells add-in, and then change the format of found cells using the Format Cells feature.

This is one of those rare tasks that are not covered in Excel help files, forums and blogs and for which there is no straightforward solution. And this is understandable, because this task is not typical. And still, if you need to change the background color of cells statically i.e. once and forever unless you change it manually again, proceed with the following steps.

Find and select all cells that meet a certain condition

There may be several possible scenarios depending on what kind of values you are looking for.

If you need to color cells with a particular value, e.g. 50, 100 or 3.4, go to the Home tab, Editing group, and click Find Select > Find….

Enter the needed values and click the Find All button.

Enter the needed values and click the Find All button.

Tip: Click the Options button in the right-hand part of the Find and Replace dialog to get a number of advanced search options, such as “Match Case” and “Match entire cell content“. You can use wildcard characters, such as an asterisk (*) to find any string of characters or a question mark (?) to find any single character.

In our previous example, if we needed to find all gas prices between 3.7 and 3.799, we would specify the following search criteria:

Use the wildcard character to find all gas prices between 3.7 and 3.799

Now select any of the found items in the lower part of the Find and Replace dialog window by clicking on it and then press Ctrl + A to select all found entries. After that click the Close button.

Select all found items and click the Close button.

This is how you select all cells with a certain value(s) using the Find All function in Excel.

However, what we actually need is to find all gas prices higher than 3.7 and regrettably Excel’s Find and Replace dialog does not allow for such things.

Luckily, there is another tool that can handle such complex conditions. The Select Special Cells add-in lets you find all values in a specified range, e.g. between -1 and 45, get the maximum / minimum value in a column, row or range, find cells by font color, fill color and much more.

Select Special Cells add-in for Excel

You click the Select by Value button on the ribbon and then specify your search criteria on the add-in’s pane, in our example we are looking for values greater than 3.7. Click the Select button and in a second you will have a result like this:

Select all values within a particular range using Select Special Cells add-in.

If you are interested to try the Select Special Cells add-in, you can download an evaluation version here.

Change the background color of selected cells using “Format Cells” dialog

Now that all cells with a specified value or values are selected (either by using Excel’s Find and Replace or Select Special Cells add-in) what is left for you to do is force the background color of selected cells to change when a value changes.

Open the Format Cells dialog by pressing Ctrl + 1 (you can also right click any of selected cells and choose “Format Cells…” from the pop-up menu, or go to Home tab > Cells group > Format > Format Cells…) and make all format changes you want. We will choose to change the background color in orange this time, just for a change 🙂

Change the background color of selected cells using the Format Cells dialog.

If you want to alter the background color only without any other format changes, then you can simply click the Fill color button and choose the color to your liking.

Change the background color of selected cells by clicking the Fill color button.

Here is the result of our format changes in Excel:

The backgrounds color of selected cells is changed permanently, regardless of the cell value

Unlike the previous technique with conditional formatting, the background color set in this way will never change again without your notice, no matter how the values change.

Change background color for special cells (blanks, with formula errors)

Like in the previous example, you can change the background color of special cells in two ways, dynamically and statically.

Use Excel formula to change background color of special cells

A cell’s color will change automatically based on the cell’s value.

This method provides a solution that you will most likely need in 99% of cases, i.e. the background color of cells will change according to the conditions you set.

We are going to use the gas prices table again as an example, but this time a couple of more states are included and some cells are empty. See how you can detect those blank cells and change their background color.

  1. On the Home tab, in the Styles group, click Conditional Formatting >New Rule… (see step 2 of How to dynamically change a cell color based on value for step-by-step guidance).
  2. In the “New Formatting Rule” dialog, select the option “Use a formula to determine which cells to format“. Then enter one of the following formulas in the “Format values where this formula is true” field:
    • =IsBlank()– to change the background color of blank cells.
    • =IsError() – to change the background color of cells with formulas that return errors.

Since we are interested in changing the color of empty cells, enter the formula =IsBlank(), then place the cursor between parentheses and click the Collapse Dialog button in the right-hand part of the window to select a range of cells, or you can type the range manually, e.g. =IsBlank(B2:H12) .

Enter the formula and select a range of cells.

A rule to change the background color of blank cells using a formula

Click the Format… button and choose the needed background color on the Fill tab (for detailed instructions, see step 5 of “How to dynamically change a cell color based on value”) and then click OK. The preview of your conditional formatting rule will look similar to this:

Click the OK button and you

If you are happy with the color, click the OK button and you’ll see the changes immediately applied to your table.

Change the background color of special cells statically

Once changed, the background color will remain the same, regardless of the cell values’ changes.

If you want to change the color of blank cells or cells with formula errors permanently, follow this way.

Open the

    Select your table or a range and press F5 to open the “Go To” dialog, and then click the “Special…” button.

Check the Blanks radio button to select all empty cells.

In the “Go to Special” dialog box, check the Blanks radio button to select all empty cells.

Just remember that formatting changes made in this way will persist even if your blank cells get filled with data or formula errors are corrected. Of course, it’s hard to imagine off the top of the head why someone may want to have it this way, may be just for historical purposes 🙂

How to get most of Excel and make challenging tasks easy

As an active user of Microsoft Excel, you know that it has plenty of features. Some of them we know and love, others are a complete mystery for an average user and various blogs, including this one, are trying to shed at least some light on them. But! There are a few very common tasks that all of us have to perform daily and Excel simply does not provide any features or tools to automate them or make an inch easier.

For example, if you need to check 2 worksheets for duplicates or merge rows from single or different spreadsheets, it would take a bunch of arcane formulas or macros and still there is no guarantee you would get the accurate results.

That was the reason why a team of our best Excel developers designed and created 70+ add-ins that we call the Ultimate Suite for Excel. These smart tools handle the most grueling, painstaking and error-prone tasks in Excel and ensure quickly, neatly and flawless results. Below is a short list of just some of the tasks the add-ins can help you with:

  • Remove duplicates and find unique values
  • Merge tables and combine data from different sources
  • Combine duplicate rows into one
  • Merge cells, rows and columns
  • Find and replacing in all data, in all workbooks
  • Generate random numbers, passwords and custom lists
  • And much, much more.

Just try these add-ins and you will see that your Excel productivity will increase up to 50%, at the very least!

That’s all for now. In my next article we will continue to explore this topic further and you will see how you can quickly change the background color of a row based on a cell value. Hope to see you on our blog next week!

Colin Wynn
the authorColin Wynn

Leave a Reply