Count Color

这篇博客主要介绍了如何利用C语言进行颜色计数查询。通过struct结构体来组织数据,实现了高效的颜色统计方法。
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 100005

struct node 
{
	int l;
	int r;
	int color;
}t[MAXN*3];
bool r[50];
void make(int st,int ed,int i)
{
	t[i].l=st;
	t[i].r=ed;
	t[i].color=1;
	if(st==ed)
	{
		return ;
	}
	int mid=(t[i].l+t[i].r)/2;
	make(st,mid,i*2);
	make(mid+1,ed,i*2+1);
}

void updata(int st,int ed,int i,int c)
{
	if(st==t[i].l&&ed==t[i].r)
	{
		t[i].color=c;
		return ;
	}
	if(t[i].color>0)
	{
		t[i*2+1].color=t[i*2].color=t[i].color;
		t[i].color=0;
	}
	int mid=(t[i].l+t[i].r)/2;
	if(st>mid)
		updata(st,ed,i*2+1,c);
	else if(ed<=mid)
		updata(st,ed,i*2,c);
	else 
	{
		updata(st,mid,i*2,c);
		updata(mid+1,ed,i*2+1,c);
	}
}


void query(int st,int ed,int i)
{
	if(t[i].color>0)
	{
		r[t[i].color]=1;
		return ;
	}
	int mid=(t[i].l+t[i].r)/2;
	if(st>mid)
		query(st,ed
# 绘图代码 p <- ggplot(data) + # 1. 添加棒棒糖的"棒"(使用中性灰色) geom_segment( aes(x = 0, xend = GeneRatio_value, y = Description, yend = Description), color = "gray85", linewidth = 0.7 ) + # 2. 添加所有点(统一映射) geom_point( aes(x = GeneRatio_value, y = Description, size = Count, # 大小映射到Count color = FDR, # 颜色映射到负对数FDR shape = ONTOLOGY), # 形状映射到ONTOLOGY stroke = 0.8 # 点边框粗细 ) + # 3. 设置颜色渐变(FDR) scale_color_gradientn( name = expression(-log[10](FDR)), # 数学表达式标签 colours = c("#2c7bb6", "#abd9e9", "#ffffbf", "#fdae61", "#d7191c"), # 蓝-黄-红渐变 values = scales::rescale(c(1, 5, 10, 15, 20)), # 颜色锚点位置 breaks = scales::pretty_breaks(n = 5), guide = guide_colorbar(order = 1) # 图例顺序控制 ) + # 4. 设置点大小(Count) scale_size_continuous( name = "Count", range = c(2, 8), # 最小和最大点大小 breaks = scales::pretty_breaks(n = 5), limits = range(data$Count), guide = guide_legend(order = 2) # 图例顺序控制 ) + # 5. 设置形状(ONTOLOGY) scale_shape_manual( name = "Ontology", values = c( "BP" = 16, # 实心圆圈 "CC" = 17, # 实心三角形 "MF" = 18 # 实心菱形 ), labels = c("Biological Process", "Cellular Component", "Molecular Function"), guide = guide_legend(order = 3, # 图例顺序控制 override.aes = list(size = 4)) # 固定图例点大小 ) + # 6. 坐标轴和标题 labs( x = "GeneRatio", y = "Description") + # 7. 主题设置 theme_bw(base_size = 12) + theme( panel.grid.major = element_line(color = "grey95", linewidth = 0.3), panel.grid.minor = element_blank(), panel.background = element_rect(fill = "#f7fcfd"), axis.text.y = element_text(color = "black", size = 9), legend.position = "right", legend.box = "vertical", legend.spacing.y = unit(10, "pt"), # 图例间垂直间距 plot.title = element_text(hjust = 0.5, face = "bold"), legend.key.height = unit(1.2, "cm") ) # 保存为矢量图 ggsave("GO_Grouped_MultiGradient.svg", p, device = "svg", width = 11, height = 9, dpi = 300)修改这个代码,纵坐标字体增大
最新发布
10-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值