ggrepel删除标签周围的线条

时间:2017-05-31 03:11:03

标签: r ggrepel

如何删除FileSystemRights : FullControl AccessControlType : Allow IdentityReference : Everyone IsInherited : False InheritanceFlags : None PropagationFlags : None 周围的行。使用def get_attachment_path(instance, filename): ext = os.path.splitext(filename)[1] d = os.path.dirname(filename) current_time = datetime.now().strftime('%Y%m%d-%H%M%S-%f')[:-3] filename = os.path.join(d, current_time + ext) return 'fW_media/bin/{}'.format(filename) class FWVersion(models.Model): bin_file = models.FileField(upload_to=get_attachment_path) name = models.CharField(max_length=64) create_time = models.DateTimeField(auto_now_add=True) class GetFWView(viewsets.ModelViewSet): queryset = FWVersion.objects.all() serializer_class = GetFWSerializer def create(self, request, *args, **kwargs): serializer = UploadFWSerializer(data=request.data) if serializer.is_valid(): instance = serializer.create(serializer.validated_data) return Response('upload success') else: return Response(serializer.errors) @list_route(methods=['GET']) def get_latest(self, request): lastest_fw = FWVersion.objects.latest('create_time') serializer = self.get_serializer(lastest_fw) return Response(serializer.data) 似乎没有明显效果。我可以设置`color

geom_label_repel

在空白label.size = 0偶尔有效后输入library(ggplot2) library(ggrepel) ggplot(mtcars, aes(wt, mpg, color = wt)) + geom_point(color = 'red') + geom_label_repel(aes(label = rownames(mtcars)), label.size = 0, fill = "white") + theme_classic(base_size = 16) ,但不可靠:这些框可能会显示在与文字不同的位置。

enter image description here

2 个答案:

答案 0 :(得分:5)

正如评论中提到的eipi10,设置label.size=NA

library(ggplot2)
library(ggrepel)
ggplot(mtcars, aes(wt, mpg, color = wt)) +
  geom_point(color = 'red') +
  geom_label_repel(aes(label = rownames(mtcars)), label.size = NA, fill = "white") +
  theme_classic(base_size = 16)

答案 1 :(得分:4)

您可以使用geom_text_repel geom。

省略标签框
library(ggplot2)
library(ggrepel)
g <- ggplot(mtcars, aes(wt, mpg, color = wt)) +
  geom_point(color = 'red') +
  theme_classic(base_size = 16)

g + geom_label_repel(aes(label = rownames(mtcars)), fill = "white")

offical documentation

g + geom_text_repel(aes(label = rownames(mtcars)))

enter image description here

另外,根据帮助页面:

  

目前geom_label_repel ...比geom_text_repel慢得多。