我想编写一个ggplot2主题,当x轴包含数值或因子时,该主题将x轴的格式设置为不同。
是否可以从主题调用中检测使用哪种类型的音阶?如果是,怎么办?
我的代码看起来像这样,我正在寻找一个表达式来替换尖括号中的伪装:
my_theme <- function(){
thm <- theme_bw() %+replace%
theme(
panel.border = element_blank()
)
if(<x-Axis scale is factor?>){
thm <- thm %+replace%
axis.ticks.x = element_blank()
}
thm
}
答案 0 :(得分:1)
<?php
if (isset($_GET['purchasecode']) && isset($_GET['itemid']) && isset($_GET['website'])) {
$purchasecode = $mysqli->real_escape_string($_GET['purchasecode']);
$website = $mysqli->real_escape_string($_GET['website']);
$itemid = $mysqli->real_escape_string($_GET['itemid']);
require_once 'class-verify.php';
$access_token = 'MyAccessTokenHere';
$purchase = new EnvatoPurchaseCodeVerifier($access_token);
$verified = $purchase->verified($purchasecode);
// Verified that user have purchased one of our items
if ($verified) {
$item_id = $verified->item->id;
$item_name = $verified->item->name;
$buyer = $verified->buyer;
$license = $verified->license;
$amount = $verified->amount;
$sold_at = $verified->sold_at;
$supported_until = $verified->supported_until;
$query = $mysqli->query("SELECT * FROM PurchaseCodes WHERE Code='".$purchasecode."' AND ItemID='".$item_id ."' AND Website='".$website."'");
if (/* puchase code, item id and website URL exist/matches */) {
echo 'License is already active!';
} elseif (/* puchase code and item id matches but website URL is different */) {
echo 'License is already actived on another website!';
} elseif ($item_id != $itemid) {
echo 'This purchase code is for our another item';
}else {
// insert into database if not already exists
$mysqli->query("INSERT IGNORE INTO PurchaseCodes (Code, ItemID, Website) VALUES ('$purchasecode', '$item_id', '$website')");
echo 'License is successfully activated!';
}
} else {
echo 'Purchase code is invalid!';
}
}
?>
是ggplot2中的一个辅助函数,它返回与绘图的图层(默认情况下为第一个geom图层)相关的比例,因此类似layer_scales
这样的内容可以告诉您x-您正在处理的轴。
这是一个如何实现的示例:
class(layer_scales(plot)$x)