Plot Squared Use Flag

Posted on

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 pvp flag
  • Denying entry to a region using the entry flag
  • Disabling the melting of snow using the snow-melt flag
  • Blocking players within the region from receiving chat using the receive-chat flag
  • Halting the growth of vines by using the vine-growth flag

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.

TypeKind of values
stateEither ‘allow’ or ‘deny’ (explained later)
stringAny form of text
integerA number that does not have decimals (5, but not 5.5)
doubleNumbers that may have decimals (5, 5.5, 2.425)
locationA location in a world
booleanTrue or false
setA 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 deny is present, the result is deny. Otherwise, if allow is present, then the final value is allow.
  • 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¶

FlagTypedescription
passthroughstate

This flag is short for ‘passthrough build’. It has nothing to do with movement.

  • If not set (default), then the region protects it area.
  • If set to deny, then the region protects its area.
  • If set to allow, then the region no longer protects its area.

Where does the flag come into use?

  • When you are using other flags (PvP, healing, etc.) and you don’t want to prevent building.
  • Why not set build to allow (explained later) instead? That would override other regions and let people build!

Protection-Related¶

FlagTypedescription
buildstate

Everything:

  • Whether blocks can be mined or placed
  • Whether doors, levers, etc. (but not inventories) can be used
  • Whether entities and blocks can be interacted with
  • Whether player versus player combat is permitted
  • Whether sleeping in a bed is permitted
  • Whether inventories can be accessed
  • Whether vehicles (boats, minecarts) can be placed
  • etc.
interactstate

Everything that involves ‘using’ a block or entity:

  • Whether doors, levers, etc. (but not inventories) can be used
  • Whether vehicles (including animals) can be mounted
  • etc.
block-breakstateWhether blocks can be mined
block-placestateWhether blocks can be placed
usestateWhether doors, levers, etc. (but not inventories) can be used
damage-animalsstateWhether players can harm friendly animals (cows, sheep, etc)
chest-accessstateWhether inventories can be accessed
ridestateWhether vehicles (including animals) can be mounted
pvpstateWhether player versus player combat is permitted
sleepstateWhether sleeping in a bed is permitted
respawn-anchorsstateWhether respawn anchors can be activated
tntstateWhether TNT detonation or damage is permitted
vehicle-placestateWhether vehicles (boats, minecarts) can be placed
vehicle-destroystateWhether vehicles can be destroyed
lighterstateWhether flint and steel can be used
block-tramplingstateWhether farmland and turtle eggs can be trampled
frosted-ice-formstateWhether players with frost walker boots will form ice
item-frame-rotationstateWhether items can be rotated within item frames
firework-damagestateWhether 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¶

FlagTypedescription
creeper-explosionstateWhether creepers can do damage
enderdragon-block-damagestateWhether enderdragons can do block damage
ghast-fireballstateWhether ghast fireballs and wither skulls can do damage
other-explosionstateWhether explosions can do damage
fire-spreadstateWhether fire can spread
enderman-griefstateWhether endermen will grief
snowman-trailsstateWhether snowmen will create snow beneath them
mob-damagestateWhether mobs can hurt players
mob-spawningstateWhether mobs can spawn
deny-spawnset of entity typesA list of entity types that cannot spawn
entity-painting-destroystateWhether non-player entities can destroy paintings
entity-item-frame-destroystateWhether non-player entities can destroy item frames
wither-damagestateWhether 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¶

FlagTypedescription
lava-firestateWhether lava can start fires
lightningstateWhether lightning can strike
water-flowstateWhether water can flow
lava-flowstateWhether lava can flow
snow-fallstateWhether snow will form tiles on the ground
snow-meltstateWhether snow will melt
ice-formstateWhether ice will form
ice-meltstateWhether ice will melt
frosted-ice-meltstateWhether frosted ice will melt
mushroom-growthstateWhether mushrooms will grow
leaf-decaystateWhether leaves will decay
grass-growthstateWhether grass will grow
mycelium-spreadstateWhether mycelium will spread
vine-growthstateWhether vines (and kelp) will grow
crop-growthstateWhether crops (wheat, potatoes, melons, etc) will grow
soil-drystateWhether soil will dry
coral-fadestateWhether 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¶

FlagTypedescription
entrystateWhether players can enter the region
exitstateWhether players can exit the region
exit-via-teleportstate

Whether players can exit the region via teleport.

This only takes effect if the player is otherwise denied exiting the region

exit-overridebooleanWhether to always allow a player to exit
entry-deny-messagestringThe message issued to players that are denied entry
exit-deny-messagestringThe message issued to players that are denied exit
notify-enterbooleanWhether players with the worldguard.notify permission are notified when another player enters the region
notify-leavebooleanWhether players with the worldguard.notify permission are notified when another player leaves the region
greetingstringThe message that appears in chat upon entering the region
greeting-titlestringThe title that appears upon entering the region. Including a newline (n) will send a subtitle.
farewellstringThe message that appears in chat upon leaving the region
farewell-titlestringThe title that appears upon leaving the region. Including a newline (n) will send a subtitle.
enderpearlstateWhether enderpearls can be used
chorus-fruit-teleportstateWhether chorus fruits can be used to teleport
teleportlocationThe location to teleport to when the /regionteleport command is used with the region name
spawnlocationThe 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¶

FlagTypedescription
item-pickupstateWhether items can be picked up
item-dropstateWhether items can be dropped
exp-dropsstateWhether XP drops are permitted
deny-messagestringThe message issued to players that are denied an action
invinciblestateWhether players are invincible
fall-damagestateWhether entities receive fall damage
game-modegamemodeThe gamemode (survival, creative, adventure) that will be applied to players that enter the region
time-lockstringTime 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-lockweatherType of weather players will see when in the region. This does not affect world mechanics. Valid values are rain and clear.
natural-health-regenstateWhether players should naturally regen health from being satiated or being in peaceful mode.
natural-hunger-drainstateWhether players should naturally lose hunger due to saturation/exhaustion levels.
heal-delayintegerThe number of seconds between heals (if heal-amount is set). Set to 0 to disable.
heal-amountintegerThe amount of half hearts to heal (or hurt if negative) the player at the rate of heal-delay
heal-min-healthdoubleThe minimum number of half hearts that damage (via heal-amount) will not exceed
heal-max-healthdoubleThe maximum number of half hearts that healing (via heal-amount) will not exceed
feed-delayintegerSee equivalent heal flag, except this is for food
feed-amountintegerSee equivalent heal flag, except this is for food
feed-min-hungerintegerSee equivalent heal flag, except this is for food
feed-max-hungerintegerSee equivalent heal flag, except this is for food
blocked-cmdsset of stringsA list of commands to block
allowed-cmdsset of stringsA 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:

Plot squared use flag symbol

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¶

FlagTypedescription
pistonsstateWhether pistons can be used
send-chatstateWhether players can send chat
receive-chatstateWhether players can receive chat
potion-splashstateWhether potions can have splash effects
9 min read2017/08/16

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 ncol and horiz arguments
  • 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

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:

optionargumentvalues
Box Typebtyo, n
Background Colorbgblue, #0000ff
Border Line Typebox.lty1:5
Border Line Widthbox.lwd0.5, 1, 1.5
Border Line Colorbox.colblue, #0000ff
Horizontal Justificationxjust0:1
Vertical Justificationyjust0:1
Text Colortext.colblue, #0000ff
Text Fonttext.font1: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 type
  • box.lwd: line width
  • box.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 justified
  • 0.5: centered
  • 1: 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 ncol and horiz arguments
  • 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