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 adjust the position of ggplot2 legend legend.position

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

Share

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

Ggplot2 drawing process, controlling the position of the legend in the diagram using theme (legend.position) parameters

The corresponding settings for this parameter are as follows:

Legend.position

The position of legends ("none", "left", "right", "bottom", "top", or two-element numeric vector)

Where none represents a hidden legend, refer to https://www..com/article/383

Other types mean to control the specific position, including "left" left, "right" right, "bottom", "top", based on the drawing process https://www..com/article/92, modify theme (legend.position)

P_bottom=p+theme (legend.position = "bottom") print (p_bottom)

But mainly, legend.position can also be controlled by a numerical vector composed of two elements, mainly by setting the specific position of the legend in the middle of the picture, rather than the periphery of the picture. The size of the value is generally between 0 and 1, and exceeding the value often causes the legend to be hidden.

C (0.9, 0.7)

P_v=p+theme (legend.position = c (0.9)) print (pairv)

C (0.9) only a small half of the illustration appears

P_v=p+theme (legend.position = c (0.9) 1. 1) print (pairv)

C (0.9 Jue 1.2) the legend is completely beyond the drawing board and can be understandably hidden

If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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