Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to choose colors according to rainbow in R language

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to take color according to rainbow in R language". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

rainbow() to get rainbow swatches

rainbow(n, s = 1, v = 1, start = 0, end = max(1, n - 1)/n, alpha = 1)

For example, 10 colors are obtained based on rainbow color gradient, which are sequentially refined by red, yellow, green, cyan, green, blue, magenta, etc.:

> rainbow(10) [1] "#FF0000FF" "#FF9900FF" "#CCFF00FF" "#33FF00FF" "#00FF66FF" "#00FFFFFF" "#0066FFFF" [8] "#3300FFFF" "#CC00FFFF" "#FF0099FF"

The corresponding colors appear as follows (draw ten incremental columns and fill them with the corresponding colors):

> barplot(1:10,col=rainbow(10))

How do I get a portion of the rainbow ribbon instead of going from red to the end position? It can be set based on the parameters start and end:

With rainbow, the parameters start and end can be used to specify particular subranges of hues. The following values can be used when generating such a subrange: red = 0, yellow = 1/6, green = 2/6, cyan = 3/6, blue = 4/6 and magenta = 5/6.

For example, color from red to blue:

> rainbow(10,start = 0,end=4/6) [1] "#FF0000FF" "#FF7100FF" "#FFE300FF" "#AAFF00FF" "#39FF00FF" "#00FF39FF" "#00FFAAFF" [8] "#00E3FFFF" "#0071FFFF" "#0000FFFF"> barplot(1:10,col=rainbow(10,start=0,end=4/6))

Start=1/6, end=5/6

> barplot(1:10,col=rainbow(10,start=1/6,end=5/6))"How to get color according to rainbow in R language" is introduced here. Thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report