Plot Squared Use Flag
I'm trying to plot in R the graph of the density function of a Chi-Squared distribution with 28 df being the x higher to 7.5. Until now I got this from what I've been able to gather around: x <. /plot flag set - configures a flag to one specific value /plot flag add - adds a command or block to a flag, specifically a PlotBlockList flag, (i.e. Use, break, place) /plot flag remove - removes a flag, cancelling it's effects Useful Flags and Common Flags /plot flag set time must be a whole number; sets the time of day on your plot.
Extensive flag system so you can decide what should be protected on a per world, or per plot basis Plot entry notifications / per plot time / weather / music etc with the flag system Add custom roads to existing maps to make them look nicer.
Plot Squared Use Flag
Regions can have flags set upon it. Some uses of flags include:
- Blocking player versus combat with the
pvpflag - Denying entry to a region using the
entryflag - Disabling the melting of snow using the
snow-meltflag - Blocking players within the region from receiving chat using the
receive-chatflag - Halting the growth of vines by using the
vine-growthflag
A region can have several different flags set at one time, although a certain flag can only have one value at a time. Flags are defined using the /regionflag command, as illustrated below for the “spawn” region and “hospital” regions:
Remove a flag by not specifying a value:
List flags by using the “flags” command:
The output of this command is interactive in-game. Click flag values to change them, and the arrows at the bottom to navigate through pages.
Region Groups¶
Sometimes, it may be desired for a flag to only apply to a certain group of players rather than everyone that should enter the region. This can be achieved by specifying an additional “region group” when defining the flag, of which there are several options:
- all (everyone)
- members
- owners
- nonmembers
- nonowners
The group can be specified using the -g marker as illustrated below:
It is not possible to set the same flag to different values for more than one group on the same region. If you need that functionality, consider making several regions.
Note
When there are multiple overlapping regions, a player must be a member of the region on which the flag is set or on one of the region’s child regions (when region inheritance is involved). This is explained further in Priority and Inheritance.
Tip
The entry and exit flags default to “non-member”, meaning setting them to “deny” will prevent non-members from entering/exiting the region. The teleport and spawn location flags default to “members”, which means that only members can take advantage of them by default. All other flags provided by WorldGuard default to “everyone”.
Types of Flags¶
Each flag is of a certain type that determines what kind of values it may take. For example, the heal-amount flag is an numeric flag, so you can only set numeric values for it.
| Type | Kind of values |
|---|---|
| state | Either ‘allow’ or ‘deny’ (explained later) |
| string | Any form of text |
| integer | A number that does not have decimals (5, but not 5.5) |
| double | Numbers that may have decimals (5, 5.5, 2.425) |
| location | A location in a world |
| boolean | True or false |
| set | A list of unique entries |
Internally, there are more types, but it should generally not be of concern.
Tip
Most string flags will accept n as a newline (for example, to send multiple lines via greeting/farewell, or a title and subtitle via greeting-title and farewell-title).
They may also accept color codes, either in the old style &[0-9a-f] or `[RrYyGgCcBbPp012w] for dark-red, red, dark yellow, yellow, etc., and [&`][klmnox] for obfuscated, bold, strikethrough, underline, and italic text.
They may also accept some replacements, such as %name% for the player’s name, %world% for world name, and %online% for player count.
Example: Using string formatting options
Setting spawn’s greeting-title to a fancy welcome message:
Conflicting Flags¶
Sometimes, a certain location may have multiple overlapping regions with different values for the same flag. The following rules are used to determine which values are selected:
- Regions will inherit the value of a flag from its parent, if the region did not have the flag set.
- Higher priority regions will override lower-priority regions.
- The global region is considered like any other region, except it is at the lowest possible priority.
However, it is still possible for there to be conflicting flag values even after that process. Imagine two different regions at the same priority, for example. At that point, the value of the flag is decided differently depending on the type of flag:
- For state flags, if
denyis present, the result isdeny. Otherwise, ifallowis present, then the final value isallow. - For other flags, the result is not defined. For that reason, do not, for example, set two different greeting messages in the same area with the same priority.
If a flag is not defined at all, then the default behavior is whichever is most sensible. For example, if “item pickup” is not defined, WorldGuard defaults to allowing it.
Flag Listing¶
Flags are broken down into categories below.
Overrides¶
| Flag | Type | description |
|---|---|---|
| passthrough | state | This flag is short for ‘passthrough build’. It has nothing to do with movement.
Where does the flag come into use?
|
Protection-Related¶
| Flag | Type | description |
|---|---|---|
| build | state | Everything:
|
| interact | state | Everything that involves ‘using’ a block or entity:
|
| block-break | state | Whether blocks can be mined |
| block-place | state | Whether blocks can be placed |
| use | state | Whether doors, levers, etc. (but not inventories) can be used |
| damage-animals | state | Whether players can harm friendly animals (cows, sheep, etc) |
| chest-access | state | Whether inventories can be accessed |
| ride | state | Whether vehicles (including animals) can be mounted |
| pvp | state | Whether player versus player combat is permitted |
| sleep | state | Whether sleeping in a bed is permitted |
| respawn-anchors | state | Whether respawn anchors can be activated |
| tnt | state | Whether TNT detonation or damage is permitted |
| vehicle-place | state | Whether vehicles (boats, minecarts) can be placed |
| vehicle-destroy | state | Whether vehicles can be destroyed |
| lighter | state | Whether flint and steel can be used |
| block-trampling | state | Whether farmland and turtle eggs can be trampled |
| frosted-ice-form | state | Whether players with frost walker boots will form ice |
| item-frame-rotation | state | Whether items can be rotated within item frames |
| firework-damage | state | Whether fireworks can deal damage to entities |
Warning
None of these flags are player-specific. For example, the block-break flag, if set to deny, prevents pistons from breaking blocks.
To understand why, consider the fact that players can fling TNT into a region from outside, or a player can build an inchworm piston machine that moves into another region. While these actions were caused by a player, realistically attempting to figure which player built the TNT cannon or used it is much more difficult. However, you still want to prevent someone from blowing up spawn with a TNT cannon.
Outright blocking TNT cannons or pistons is the wrong solution. Pistons and TNT cannons should be allowed in some cases. For example, a TNT cannon or piston inside should work within the region.
First off, remember who can build in regions: it’s not players, it’s members. When we consider pistons or TNT, it should be no different. How does WorldGuard figure out whether a piston machine or TNT cannon is a member of a region? If it’s inside the region, of course!
When you create a region, before setting any flags on it:
- Members may build
- Non-members may not build
TNT cannons and pistons inside are allowed to work because they are “members.” An imaginary player, “Bobby,” who isn’t a member yet, is unable to place or break blocks. Once you add Bobby to the region, then Bobby can build.
When you set the protection flags, you override this behavior. If you set block-break to deny, then even members are unable to break blocks. Bobby cannot break blocks. A TNT cannon inside cannot break blocks. A piston inside cannot break blocks. You break pistons.
That raises two questions:
- How do I prevent players from placing or breaking blocks? Don’t do anything. Don’t change any flags! Remember, only members can build by default.
- How do I change a flag to only affect players? You probably mean: how do you make a flag only affect non-members? Well, that’s easy: use Region Groups.
Tip
Note: If the build flag is set to allow or deny, it can still be overriden with a different flag (block-break, interact, etc.).
Mobs, Fire, and Explosions¶
| Flag | Type | description |
|---|---|---|
| creeper-explosion | state | Whether creepers can do damage |
| enderdragon-block-damage | state | Whether enderdragons can do block damage |
| ghast-fireball | state | Whether ghast fireballs and wither skulls can do damage |
| other-explosion | state | Whether explosions can do damage |
| fire-spread | state | Whether fire can spread |
| enderman-grief | state | Whether endermen will grief |
| snowman-trails | state | Whether snowmen will create snow beneath them |
| mob-damage | state | Whether mobs can hurt players |
| mob-spawning | state | Whether mobs can spawn |
| deny-spawn | set of entity types | A list of entity types that cannot spawn |
| entity-painting-destroy | state | Whether non-player entities can destroy paintings |
| entity-item-frame-destroy | state | Whether non-player entities can destroy item frames |
| wither-damage | state | Whether withers can do damage (with their body explosions - skull projectiles are handled by ghast-fireball as mentioned above) |
Example: Preventing sheep and cows from spawning at spawn
The entity types must be specified:
Natural Events¶
| Flag | Type | description |
|---|---|---|
| lava-fire | state | Whether lava can start fires |
| lightning | state | Whether lightning can strike |
| water-flow | state | Whether water can flow |
| lava-flow | state | Whether lava can flow |
| snow-fall | state | Whether snow will form tiles on the ground |
| snow-melt | state | Whether snow will melt |
| ice-form | state | Whether ice will form |
| ice-melt | state | Whether ice will melt |
| frosted-ice-melt | state | Whether frosted ice will melt |
| mushroom-growth | state | Whether mushrooms will grow |
| leaf-decay | state | Whether leaves will decay |
| grass-growth | state | Whether grass will grow |
| mycelium-spread | state | Whether mycelium will spread |
| vine-growth | state | Whether vines (and kelp) will grow |
| crop-growth | state | Whether crops (wheat, potatoes, melons, etc) will grow |
| soil-dry | state | Whether soil will dry |
| coral-fade | state | Whether coral will die when not in water. |
Warning
The fire-spread, water-flow and liquid-flow flags require that the “high frequency flags” option be enabled in the configuration. This is because these events can be very frequent, requiring more region lookups, and potentially slowing down your server (or at least warming the server room a bit more).
Movement¶
| Flag | Type | description |
|---|---|---|
| entry | state | Whether players can enter the region |
| exit | state | Whether players can exit the region |
| exit-via-teleport | state | Whether players can exit the region via teleport. This only takes effect if the player is otherwise denied exiting the region |
| exit-override | boolean | Whether to always allow a player to exit |
| entry-deny-message | string | The message issued to players that are denied entry |
| exit-deny-message | string | The message issued to players that are denied exit |
| notify-enter | boolean | Whether players with the worldguard.notify permission are notified when another player enters the region |
| notify-leave | boolean | Whether players with the worldguard.notify permission are notified when another player leaves the region |
| greeting | string | The message that appears in chat upon entering the region |
| greeting-title | string | The title that appears upon entering the region. Including a newline (n) will send a subtitle. |
| farewell | string | The message that appears in chat upon leaving the region |
| farewell-title | string | The title that appears upon leaving the region. Including a newline (n) will send a subtitle. |
| enderpearl | state | Whether enderpearls can be used |
| chorus-fruit-teleport | state | Whether chorus fruits can be used to teleport |
| teleport | location | The location to teleport to when the /regionteleport command is used with the region name |
| spawn | location | The location to teleport to when a player dies within the region |
Tip
As mentioned above, the teleport and spawn location flags default to “members”, which means that only members can take advantage of them by default. Set the region group for the flag to change this.
Warning
The greeting and farewell message flags require that the “use player move event” option not be disabled in the configuration.
Example: Preventing non-members of a “secret_club” region from entering it
The key is to set the region group to “nonmembers”:
Map Making¶
| Flag | Type | description |
|---|---|---|
| item-pickup | state | Whether items can be picked up |
| item-drop | state | Whether items can be dropped |
| exp-drops | state | Whether XP drops are permitted |
| deny-message | string | The message issued to players that are denied an action |
| invincible | state | Whether players are invincible |
| fall-damage | state | Whether entities receive fall damage |
| game-mode | gamemode | The gamemode (survival, creative, adventure) that will be applied to players that enter the region |
| time-lock | string | Time of day in ticks (between 0 and 24000) that players will see the world as while in the region. Use + or - for time relative to the world time. |
| weather-lock | weather | Type of weather players will see when in the region. This does not affect world mechanics. Valid values are rain and clear. |
| natural-health-regen | state | Whether players should naturally regen health from being satiated or being in peaceful mode. |
| natural-hunger-drain | state | Whether players should naturally lose hunger due to saturation/exhaustion levels. |
| heal-delay | integer | The number of seconds between heals (if heal-amount is set). Set to 0 to disable. |
| heal-amount | integer | The amount of half hearts to heal (or hurt if negative) the player at the rate of heal-delay |
| heal-min-health | double | The minimum number of half hearts that damage (via heal-amount) will not exceed |
| heal-max-health | double | The maximum number of half hearts that healing (via heal-amount) will not exceed |
| feed-delay | integer | See equivalent heal flag, except this is for food |
| feed-amount | integer | See equivalent heal flag, except this is for food |
| feed-min-hunger | integer | See equivalent heal flag, except this is for food |
| feed-max-hunger | integer | See equivalent heal flag, except this is for food |
| blocked-cmds | set of strings | A list of commands to block |
| allowed-cmds | set of strings | A list of commands to whitelist (any unallowed commands will be blocked) |
Warning
The healing and feeding flags require that the “use player move event” option not be disabled in the configuration.
Example: Changing the message players receive when an action they try is blocked
Set the deny-message flag:

Example: Blocking the “/tp” and “/teleport” commands at spawn
The commands in question can be blocked with:
Example: In a “hospital” region, heal players one heart every second up to half their health bar
Without any buffs, the player’s maximum health is 20, so 10 is half of that:
Miscellaneous¶
| Flag | Type | description |
|---|---|---|
| pistons | state | Whether pistons can be used |
| send-chat | state | Whether players can send chat |
| receive-chat | state | Whether players can receive chat |
| potion-splash | state | Whether potions can have splash effects |
Introduction
This is the eighth post in the series Data Visualisation With R. In the previous post, we learnt to build histograms. In this post, we will learn how to:
- position the legend within the plot
- modify the layout using
ncolandhorizarguments - add title using the
titleset of arguments - modify the appearance and position of the legend box
- modify the appearance of the text in the legend box
Legends are used to convey information about the data being represented by a plot. To understand the importance of legends, let us look at the two plots below. In the first plot, would you be able to understand what the lines represent in the absence of a legend? May be yes but only if the author provides information in a textual form outside the plot. While such information will be useful, it will also be very inconvenient. Now look at the second plot, from the legend at the top right we can easily interpret what the lines represent. Would you agree that a legend is integral to plot representing multiple data? If yes, let us go ahead and learn how to add a legend to different plots.
Since we have looked at a line graph in the above example, we will learn how to add a legend to a line graph. After that, we will generalise the steps to different plots.
Libraries, Code & Data
All the data sets used in this post can be found here and code can be downloaded from here.
Data
Let us build a line graph that represents annual economic growth (GDP) data of the BRICS nations for the years 2010-14.
Line Graph
Below is the line graph that represents the above GDP data set:
Without a legend, it will be very difficult to map the lines to the BRICS nations. We will add a legend to the above plot using the legend() function and do so one step at a time.
Legend Location
In order to add a legend to the plot, the first thing we must specify is the location of the legend in the plot. There are 2 ways to do this:
- use x and y axis coordinates
- use keywords
The list of keywords include:
- top
- bottom
- left
- right
- center
- bottomright
- bottomleft
- topright
- topleft
But there is a glitch. If we do not specify what goes into the legend, the legend() function will return an error. Before we experiment with the location of the legend inside the plot, we need to learn about another argument used to specify the content of the legend. The argument is also named legend. It takes a vector as input. In the next example, we will plot the GDP data for India and China and add a basic legend.
You can see that a legend has been added bases on the X and Y axis coordinates we specified in the legend() function. But the legend is incomplete and a user still cannot map the lines to the countries using the legend. We will learn how to add lines inside the legend shortly but before that let us use keywords to position the legend inside the plot.
You can either use the keywords or the axis coordinates to position the legend inside the plot. Use the coordinates method if you want greater control over the position of the legend. Next step is to add lines inside the legend so that a user can map the lines in the plots to the countries.
Lines
Adding a line in the legend is very simple. Use the lty argument to specify the line type and the col argument to add color to the line.
Now we can map the lines to the respective countries using the legend. But our legend looks very simple right. Let us explore the options available to modify and enhance the appearance of the legend.
Points
If the plot has both lines and points, we can use the pch argument in the legend() function to specify the shape of the point.
Text Placement
The contents of the legend can be positioned horizontally using the horiz argument. It takes logical values as inputs and the default is FALSE. Set it to TRUE to position the contents horizontally:
Another way to position the content inside the legend is to use columns. In the below example, we use the ncol argument to split the contents of the legend into two columns instead of the default one.
The below plots show the difference in appearance:
Title
Let us add a title to the legend using the title argument:
Title Color
The color of the title can be modified using the title.col argument:
Plot Squared 1.16
Title Position
The title can be positioned within the legend box using the title.adj argument. It will take values between 0 and 1. The default is 0.5 and the title is positioned in the middle of the box. As the value moves away from 0.5, the position of the title moves to the left or right respectively.
The below plots show the relative position of the title within the legend box for different values between 0 and 1.
Box Appearance
There are a lot of options to modify the appearance of the legend box. The below table displays the arguments and their descriptions. Let us look at them one by one:
| option | argument | values |
|---|---|---|
| Box Type | bty | o, n |
| Background Color | bg | blue, #0000ff |
| Border Line Type | box.lty | 1:5 |
| Border Line Width | box.lwd | 0.5, 1, 1.5 |
| Border Line Color | box.col | blue, #0000ff |
| Horizontal Justification | xjust | 0:1 |
| Vertical Justification | yjust | 0:1 |
| Text Color | text.col | blue, #0000ff |
| Text Font | text.font | 1:5 |
Box Type
The bty argument takes two values, o and n. If set to n, there will be no box around the legend.
Background Color
A background color can be added to the legend box using the bg argument. Below is an example:
Border
The following arguments can be used to modify the border of the legend box:
box.lty: line typebox.lwd: line widthbox.col: color
Justification
The xjust and yjust arguments can be used to position the legend relative to the X and Y axis respectively. Listed below is the value and the respective justification:
0: left justified0.5: centered1: right justified
Let us look at a few examples to understand how it works.
Vertical Justification
Plot Squared Use Flag Png
Text Appearance
The last topic we will explore is the appearance of the text inside the legend box. We will modify the color and font of text using the text.col and text.font arguments.
Summary
In this post, we learnt to add legend to a plot using the legend() function. Specifically, we learnt to
- position the legend within the plot
- modify the layout using
ncolandhorizarguments - add title using the
title.set of arguments - modify the appearance and position of the legend box
- modify the appearance of the text in the legend box